🔢 GCD & LCM Calculator

Enter two or more positive whole numbers, separated by commas or spaces, to find their greatest common divisor and least common multiple.

Euclid's algorithm, folded across the list

The GCD of a pair comes from repeated remainders, and the LCM is built from it. Longer lists fold the pair rule left to right:

gcd(a, b) = gcd(b, a mod b)   until b = 0
lcm(a, b) = a / gcd(a, b) × b

Take the default 24, 36, 60. For 24 and 36: 36 mod 24 = 12, then 24 mod 12 = 0, so the GCD is 12 and the LCM is 24 / 12 × 36 = 72. Fold in 60 and the GCD stays 12 while the LCM becomes 72 / 12 × 60 = 360 - the smallest number all three divide into.

What the inputs accept, and what the answers are for

Inputs above roughly 9 trillion are refused, because past that JavaScript integers stop being exact.

Frequently asked questions

What is the GCD of 24 and 36?

12. Both are divisible by 2, again by 2, and by 3, and those factors multiply out to 12.

What is the LCM of 4, 6 and 10?

60. It is the first number 4, 6 and 10 all divide into exactly: 15, 10 and 6 times over.

Does the GCD times the LCM equal the product of the numbers?

Only for exactly two of them: 12 times 72 is 864, and so is 24 times 36. For 24, 36 and 60 the GCD times the LCM is 4,320 while the product is 51,840.