GCD and LCM: A Simple 7 Step Playbook That Works
Most mistakes with gcd and lcm come from using the wrong one, not from bad arithmetic. This playbook gives you seven steps and two checklists that settle which one you need, find it with the Euclidean algorithm and prove the answer before you rely on it.
Gcd and lcm frequently asked questions
What is the difference between GCD and LCM?
The GCD is the largest number that divides all the inputs. The LCM is the smallest number that all the inputs divide. One shrinks to a shared piece, the other grows to a shared meeting point.
How do I find the GCD of two numbers?
Divide the larger by the smaller, keep the remainder and repeat with the smaller number and the remainder. When the remainder is 0, the last divisor is the GCD.
Is GCD the same as HCF?
Yes. HCF stands for highest common factor, the name used in some countries. It means the same as greatest common divisor.
How do I get the LCM from the GCD in gcd and lcm work?
Divide one number by the GCD and multiply the result by the other. For 18 and 24 the GCD is 6, so the LCM is 3 × 24 = 72.
Can I run gcd and lcm on three numbers?
Yes. Find the GCD of the first two, then the GCD of that result and the third. The order does not change the answer.
What is the GCD when numbers share no factors?
It is 1, and the numbers are called coprime. Their LCM is simply their product.
Which one do you need: a decision list for gcd and lcm
Ask what the problem is doing. If it splits something into equal pieces, you want the greatest common divisor. If it waits for repeating events to meet, you want the least common multiple. Every gcd and lcm question starts with this split.
| The problem says | Use | Why |
|---|---|---|
| Cut into the largest equal squares or groups | GCD | You want the biggest size that fits with nothing left over |
| Simplify a fraction | GCD | Divide top and bottom by the largest shared factor |
| Add or subtract fractions | LCM | The smallest shared denominator keeps numbers small |
| When will two cycles line up again | LCM | The first time both counts reach a whole number of turns |
| Share items so every group is identical | GCD | The most groups possible is the GCD |
The 7 step playbook
- Name the questionDecide GCD or LCM using the table above. Write the question in one line before any numbers.
- Clean the inputsUse positive whole numbers. Zero is not allowed, and signs are dropped because both measures are defined on positive values.
- Run the Euclidean algorithm for gcd and lcmDivide the larger by the smaller, keep the remainder, then repeat with the smaller number and the remainder until the remainder is 0. The last non zero remainder is the GCD.
- Derive the LCMCompute (a ÷ GCD) × b. Dividing first keeps the numbers smaller.
- VerifyCheck that the GCD divides both inputs and that both inputs divide the LCM. For two numbers also check GCD × LCM = a × b.
- Extend to a listFor three or more numbers, fold from the left: GCD(a, b, c) = GCD(GCD(a, b), c). Do the same for LCM.
- Say the gcd and lcm answer in wordsAttach the unit and the meaning: tile size in centimetres, a number of minutes, a denominator.
Worked example: 48 and 180
Step 3 on paper. Each row divides the previous divisor by the previous remainder.
| Step | Division | Quotient | Remainder |
|---|---|---|---|
| 1 | 180 = 48 × 3 + 36 | 3 | 36 |
| 2 | 48 = 36 × 1 + 12 | 1 | 12 |
| 3 | 36 = 12 × 3 + 0 | 3 | 0 |
The remainder hits 0 on step 3, so the GCD is 12. For the LCM, 48 ÷ 12 = 4 and 4 × 180 = 720. Check: 720 ÷ 48 = 15 and 720 ÷ 180 = 4, both exact. Product test: 12 × 720 = 8,640 and 48 × 180 = 8,640. That is a full gcd and lcm answer with proof.
The same answer from prime factors
If you prefer factors, take the lowest power of each prime for the GCD and the highest power for the LCM. A prime factorization tool lists the factors.
| Prime | In 48 | In 180 | GCD takes (lowest) | LCM takes (highest) |
|---|---|---|---|---|
| 2 | 2⁴ | 2² | 2² | 2⁴ |
| 3 | 3¹ | 3² | 3¹ | 3² |
| 5 | none | 5¹ | none | 5¹ |
| Result | 4 × 3 = 12 | 16 × 9 × 5 = 720 |
GCD(36, 60) = 12. Then LCM = (36 ÷ 12) × 60 = 3 × 60 = 180. The product 2160 is GCD × LCM, not the LCM.
Three real problems solved with the playbook
A floor is 360 cm by 240 cm. What is the largest square tile that fits with no cutting? That is a GCD problem. GCD(360, 240) = 120, so the tile is 120 cm. The floor takes (360 ÷ 120) × (240 ÷ 120) = 3 × 2 = 6 tiles.
One machine finishes a cycle every 18 minutes and another every 24 minutes. They both finish together at time zero. When do they next finish together? That is an LCM problem. GCD(18, 24) = 6, so LCM = (18 ÷ 6) × 24 = 72. They line up again after 72 minutes.
Add 5/12 and 7/18. Use the LCM of the denominators. GCD(12, 18) = 6, so LCM = 36. Convert: 5/12 = 15/36 and 7/18 = 14/36. The sum is 29/36, already in lowest terms.
Three lights cycle every 6, 8 and 10 seconds. After how many seconds do all three turn green together, if they start together? LCM(6, 8, 10) = 120 seconds. That is 20 cycles of the first, 15 of the second and 12 of the third.
Three or more numbers, and one trap
Take 12, 18 and 30. GCD(12, 18) = 6, then GCD(6, 30) = 6. For the LCM, LCM(12, 18) = 36, then LCM(36, 30) = 180. So the GCD is 6 and the LCM is 180.
For two numbers, GCD × LCM = a × b. For three it fails: 6 × 180 = 1,080 but 12 × 18 × 30 = 6,480. Use the test on pairs only.
When the two numbers share nothing, they are called coprime, and the GCD is 1. Then the LCM is just the product. GCD(35, 18) = 1, so LCM(35, 18) = 630.
Why the Euclidean method is so fast
Euclid described it around 300 BC. It needs no factoring. Gabriel Lamé proved in 1844 that the number of steps is never more than five times the number of digits in the smaller input. The worst case is two neighbouring Fibonacci numbers. For 89 and 55, the algorithm needs 9 divisions, which fits under the bound of 5 × 2 = 10.
| Inputs | GCD | Division steps | Bound (5 × digits of smaller) |
|---|---|---|---|
| 180 and 48 | 12 | 3 | 10 |
| 1071 and 462 | 21 | 3 | 15 |
| 89 and 55 | 1 | 9 | 10 |
Big inputs matter too. Ordinary floating point numbers lose exactness above 2⁵³, which is 9,007,199,254,740,992. The tool uses BigInt arithmetic, so GCD(123456789012, 987654321098) = 2 and the LCM comes out exactly as 60,966,315,568,292,943,087,588. Read the Euclidean algorithm article on Wikipedia for the full proof.
Common slips the playbook prevents
| Slip | Example | Fix |
|---|---|---|
| Using the product as the LCM | 48 × 180 = 8,640, but the LCM is 720 | Divide the product by the GCD, or use (a ÷ GCD) × b |
| Using LCM when the problem needs GCD | Tiles for a 360 by 240 floor: 720 cm is absurd, 120 cm is right | Reread the question: equal pieces mean GCD |
| Multiplying denominators every time | 5/12 + 7/18 over 216 gives 174/216, which still needs reducing to 29/36 | Use LCM 36 from the start |
| Forgetting that coprime numbers have GCD 1 | GCD(35, 18) is 1, not 0 or 18 | A result of 1 is valid and common |
| Applying the product test to three numbers | 6 × 180 is not 12 × 18 × 30 | Use it on pairs only |
Notice that the second row would pass a quick glance but fail the unit test: a tile larger than the floor makes no sense. This is why the playbook ends by saying the answer in words.
After you find a common divisor, a fraction to decimal converter turns the reduced fraction into a decimal.
Paste two numbers or a whole list and read the Euclidean trace, the GCD and the LCM in one screen.
Open the GCD and LCM CalculatorSources: Wikipedia: Euclidean algorithm
