GCD and LCM: A Simple 7 Step Playbook That Works cover image
Prateek Zare

Written by Prateek Zare

Software Developer with ML and Data Expertise, 8+ years of experience

Last updated

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.

Short answerThe GCD is the largest number that divides all your numbers. The LCM is the smallest number that all of them divide. Find the GCD with repeated division, then LCM = (a ÷ GCD) × b. For 48 and 180 the GCD is 12 and the LCM is 720. The GCD and LCM Calculator shows every division step.

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.

Choosing between GCD and LCM
The problem saysUseWhy
Cut into the largest equal squares or groupsGCDYou want the biggest size that fits with nothing left over
Simplify a fractionGCDDivide top and bottom by the largest shared factor
Add or subtract fractionsLCMThe smallest shared denominator keeps numbers small
When will two cycles line up againLCMThe first time both counts reach a whole number of turns
Share items so every group is identicalGCDThe most groups possible is the GCD

The 7 step playbook

  1. Name the questionDecide GCD or LCM using the table above. Write the question in one line before any numbers.
  2. Clean the inputsUse positive whole numbers. Zero is not allowed, and signs are dropped because both measures are defined on positive values.
  3. 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.
  4. Derive the LCMCompute (a ÷ GCD) × b. Dividing first keeps the numbers smaller.
  5. VerifyCheck that the GCD divides both inputs and that both inputs divide the LCM. For two numbers also check GCD × LCM = a × b.
  6. 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.
  7. Say the gcd and lcm answer in wordsAttach the unit and the meaning: tile size in centimetres, a number of minutes, a denominator.
Checklist A: before you calculate gcd and lcm

Worked example: 48 and 180

Step 3 on paper. Each row divides the previous divisor by the previous remainder.

Gcd and lcm: Euclidean algorithm trace for 180 and 48
StepDivisionQuotientRemainder
1180 = 48 × 3 + 36336
248 = 36 × 1 + 12112
336 = 12 × 3 + 030

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 factor method for gcd and lcm of 48 and 180
PrimeIn 48In 180GCD takes (lowest)LCM takes (highest)
22⁴2²2²2⁴
33¹3²3¹3²
5none5¹none5¹
Result4 × 3 = 1216 × 9 × 5 = 720
Using gcd and lcm, what is the LCM of 36 and 60?

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.

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.

The gcd and lcm product test only works for two numbers

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.

Gcd and lcm number of division steps
InputsGCDDivision stepsBound (5 × digits of smaller)
180 and 4812310
1071 and 46221315
89 and 551910

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

Gcd and lcm mistakes, what they cost and the fix
SlipExampleFix
Using the product as the LCM48 × 180 = 8,640, but the LCM is 720Divide the product by the GCD, or use (a ÷ GCD) × b
Using LCM when the problem needs GCDTiles for a 360 by 240 floor: 720 cm is absurd, 120 cm is rightReread the question: equal pieces mean GCD
Multiplying denominators every time5/12 + 7/18 over 216 gives 174/216, which still needs reducing to 29/36Use LCM 36 from the start
Forgetting that coprime numbers have GCD 1GCD(35, 18) is 1, not 0 or 18A result of 1 is valid and common
Applying the product test to three numbers6 × 180 is not 12 × 18 × 30Use 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.

Checklist B: after you calculate gcd and lcm

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 Calculator

Sources: Wikipedia: Euclidean algorithm