GCD & LCM Calculator (greatest common divisor)

Find the greatest common divisor and least common multiple of two or more whole numbers, with the prime-factor reasoning explained.

Two or more whole numbers, separated by commas or spaces.
GCD (greatest common divisor)
LCM (least common multiple)
Coprime?
Numbers used

Greatest common divisor and least common multiple

The GCD of a set of whole numbers is the largest number that divides all of them exactly. The LCM is the smallest number they all divide into. They're two sides of the same relationship, and both come up constantly when simplifying fractions or lining up repeating cycles.

GCD(a, b) × LCM(a, b) = a × b

How they're found

One way is prime factorisation: the GCD takes the lowest power of each shared prime, and the LCM takes the highest power of every prime that appears. For 48 = 2⁴ × 3 and 18 = 2 × 3², the shared primes give GCD = 2 × 3 = 6, and taking the highest powers gives LCM = 2⁴ × 3² = 144. This calculator uses the faster Euclidean algorithm, which repeatedly replaces the larger number with the remainder until nothing is left over — the same answer without factorising anything.

What they're for

Dividing a fraction's top and bottom by their GCD reduces it to lowest terms. The LCM gives the common denominator when adding fractions, and it answers "when do these cycles line up again?" — two events every 4 and 6 days coincide every 12.

Worked example

For 48 and 18: the GCD is 6 and the LCM is 144. Check the identity — 6 × 144 = 864, and 48 × 18 = 864 as well. When the GCD is 1 the numbers share no factors and are called coprime; 17 and 5 are an example, and their LCM is simply their product, 85.

Whole numbers only

The greatest common divisor and least common multiple are defined for integers, so decimals are not meaningful input — scale them to whole numbers first if you need to. The calculation itself is exact, using Euclid's algorithm, and remains fast even for very large values. The one thing to watch is that the LCM of several large numbers grows quickly and can become an impractically big number long before it becomes an inaccurate one.