GCD and LCM Calculator

HCF (GCD) and LCM of two or more numbers, with Euclid steps, prime factorisation, and the simplest ratio.

How it works

Type two or more whole numbers. The tool gives the GCD (also called HCF, the biggest number that divides all of them) and the LCM (the smallest number all of them divide into). It shows Euclid steps for the first two numbers and the prime factors of each number, so you can write the working in an exam.

The simplest ratio row divides every number by the GCD.

The formula

Euclid: gcd(a, b) = gcd(b, a mod b).   lcm(a, b) = a x b / gcd(a, b)

Worked example

12, 18 and 24: 12 = 2^2 x 3, 18 = 2 x 3^2, 24 = 2^3 x 3. GCD takes the lowest power of each prime: 2 x 3 = 6. LCM takes the highest: 2^3 x 3^2 = 72.

Good to know

Common questions

What is the difference between HCF and GCD?
Nothing. HCF (highest common factor) is the school name, GCD the usual maths name.
What does co-prime mean?
The GCD is 1, so the numbers share no factor except 1.
Can I use negative numbers or zero?
No. Use whole numbers above 0.
How large can the numbers be?
Up to 30 digits each. Prime factors are shown for the numbers where this finishes quickly.

More in Utilities.