GCD & LCM Calculator

Enter two or more whole numbers separated by commas or spaces to get their greatest common divisor (GCD, also called GCF or HCF) and least common multiple (LCM), with the working shown.

Enter two or more numbers, then press Calculate.

GCD and LCM defined

The greatest common divisor (GCD, also GCF or HCF) of two numbers is the largest whole number that divides both exactly. The least common multiple (LCM) is the smallest positive number that both divide into. They're linked by a tidy identity:

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

So once you have the GCD, the LCM follows as a × b ÷ GCD. For more than two numbers, both are computed pairwise — fold the GCD (or LCM) across the list one number at a time.

Worked example

For 12, 18 and 30:

GCD: common factors of all three → 6.
LCM: 12 = 2²·3, 18 = 2·3², 30 = 2·3·5 → take the highest power of each prime: 2²·3²·5 = 180.
Result: GCD = 6, LCM = 180.

The Euclidean algorithm

The fastest way to find a GCD is the Euclidean algorithm: repeatedly replace the larger number with the remainder of dividing it by the smaller, until the remainder is 0 — the last non-zero value is the GCD. It's far quicker than listing every factor. The calculator shows the prime factorization of each input so you can see where the common and combined factors come from. GCD is handy for reducing fractions; LCM for finding common denominators or scheduling repeating events.

Tip: reducing a fraction? The fraction calculator uses the GCD automatically. Checking whether a number is prime? Use the prime number checker.

Frequently asked questions

What's the difference between GCD and LCM?

The GCD is the largest number that divides all your inputs; the LCM is the smallest number that all your inputs divide into. GCD shrinks (it's at most the smallest input); LCM grows (it's at least the largest input).

Is GCF the same as GCD?

Yes. Greatest common factor (GCF), greatest common divisor (GCD) and highest common factor (HCF) are three names for the same thing — the largest whole number that divides every input exactly.

How do you find the LCM from the GCD?

Use LCM(a, b) = a × b ÷ GCD(a, b). For more than two numbers, fold this pairwise: LCM of the first two, then the LCM of that result with the next number, and so on.

What if I enter a zero?

GCD(n, 0) is defined as n, and the LCM involving 0 is 0, because 0 is a multiple of every number. The calculator follows these standard conventions.

MB
Mustafa Bilgic · Editor, Calcool
Uses the Euclidean algorithm for the GCD and the GCD × LCM = product identity. Everything runs in your browser — nothing you enter is uploaded, logged or stored.

Related calculators