How to Find the LCM and GCD of Numbers

Find the greatest common divisor with Euclid's method, then the least common multiple from it. Worked examples and how the two relate for any list of whole numbers.

Updated 5 min read By CodingEagles
Free tool LCM and GCD Calculator Least common multiple and greatest common divisor. Open tool

The greatest common divisor (GCD) is the largest number that divides every value in a list exactly. The least common multiple (LCM) is the smallest number that every value divides into. Find the GCD with Euclid’s method, then get the LCM from it. The LCM and GCD calculator does both for any list of whole numbers.

Here is how each one works.

Finding the GCD with Euclid’s method

Euclid’s method finds the greatest common divisor quickly, even for large numbers. Repeatedly replace the larger number with the remainder of dividing it by the smaller, until the remainder reaches zero. The last non-zero value is the GCD.

Take 48 and 18:

StepCalculationRemainder
148 ÷ 1812
218 ÷ 126
312 ÷ 60

The last non-zero remainder is 6, so the GCD of 48 and 18 is 6. The method works because any number that divides both 48 and 18 also divides their remainder, so the common divisors are preserved at every step.

Finding the LCM

Once you have the GCD, the least common multiple of two numbers follows from a simple relationship: their LCM times their GCD equals their product. Rearranged, that is LCM = a × b ÷ GCD.

For 6 and 8, the GCD is 2, so the LCM is 6 × 8 ÷ 2 = 24. Checking: 24 is a multiple of both 6 and 8, and no smaller number is, so it is correct. Dividing by the GCD first avoids the numbers getting unnecessarily large.

More than two numbers

For a longer list, work two numbers at a time. Find the GCD of the first two, then the GCD of that result with the third, and so on. The LCM extends the same way. So for 12, 18 and 24 the GCD is 6 and the LCM is 72. The LCM and GCD calculator does this across the whole list at once.

What each is used for

The two have different jobs:

  • GCD reduces a fraction to lowest terms, by dividing the numerator and denominator by it.
  • LCM gives the lowest common denominator when adding or comparing fractions.
  • LCM also tells you when two repeating cycles line up again, like two events with different periods.

Where this comes up

These appear most in fraction work and in scheduling:

  • Simplifying fractions, using the GCD of the top and bottom.
  • Adding fractions, using the LCM of the denominators, covered in how to add fractions.
  • Repeating events, using the LCM of their cycle lengths to find the next overlap.

Open the LCM and GCD calculator to find both for your own numbers.

Frequently asked questions

What is the difference between LCM and GCD?
The greatest common divisor is the largest number that divides every value with no remainder. The least common multiple is the smallest number that every value divides into. GCD is used to simplify fractions; LCM is used to find common denominators.
How is the GCD calculated with Euclid's method?
Replace the larger number with the remainder of dividing it by the smaller, and repeat until the remainder is zero. The last non-zero value is the GCD. For 48 and 18: 48 mod 18 = 12, 18 mod 12 = 6, 12 mod 6 = 0, so the GCD is 6.
How are LCM and GCD related?
For two numbers, LCM × GCD equals the product of the numbers, so LCM = a × b ÷ GCD. For 6 and 8, the GCD is 2, so the LCM is 6 × 8 ÷ 2 = 24. The LCM and GCD calculator uses this to find both quickly.

Ready to try it?

Least common multiple and greatest common divisor. Free, in-browser, and 100% private — your data never leaves your device.

Open the LCM and GCD Calculator