Boneyard Tools

GCD and LCM: how to find them by hand

Understand greatest common divisor and least common multiple, the prime-factor and Euclid methods, and where each one is actually useful.

Two questions about shared numbers

Every pair of whole numbers shares factors and shares multiples. The greatest common divisor asks what is the largest number that goes into both of them, while the least common multiple asks what is the smallest number they both go into. These two ideas turn up constantly when you reduce fractions, sync repeating events, or scale a recipe. Knowing which one a problem needs is usually half the battle.

The prime factorization method

Break each number into its prime factors and the two answers fall out directly. For the GCD, take every prime the numbers have in common raised to the lowest power that appears. For the LCM, take every prime that appears in any number raised to the highest power. With 12 = 2 squared times 3 and 18 = 2 times 3 squared, the GCD is 2 times 3 = 6 and the LCM is 2 squared times 3 squared = 36. This method is slow for big numbers but makes the logic obvious.

Euclid's algorithm, the fast way

For large values, factoring is painful, so this tool uses Euclid's algorithm instead. Divide the larger number by the smaller, keep the remainder, and repeat with the smaller number and that remainder until the remainder is zero. The last non-zero value is the GCD. Because each step shrinks the numbers quickly, it finishes in a handful of iterations even for values with many digits, which is why it powers everything from calculators to cryptography libraries.

Extending both to a whole list

To handle three or more numbers you do not need a new formula. Compute the GCD of the first two, then take the GCD of that result with the third number, and continue down the list. The same folding trick works for the LCM. This associativity is why the calculator accepts an arbitrarily long list and still returns a single GCD and a single LCM.

Frequently asked questions

When would I use the LCM in real life?

The LCM finds when repeating cycles line up again. If one task runs every 12 days and another every 18, they coincide every lcm(12, 18) = 36 days. It is also the common denominator you need when adding fractions.

Can the GCD ever be larger than my smallest number?

No. The GCD divides every value, so it can never exceed the smallest number in the list. If all numbers are equal, the GCD equals that shared value.