ToolLineup

GCD & LCM Calculator

Find the greatest common divisor (also called the highest common factor) and the lowest common multiple of two or more whole numbers. Both are exact at any size — there is no cut-off at 9,007,199,254,740,991 the way there is in calculators built on ordinary numeric types, so numbers with twenty digits give the right answer rather than a rounded one. For a pair of numbers the Euclidean algorithm is shown line by line, along with Bézout’s identity, which writes the GCD as a combination of the two inputs and is the step that matters for modular inverses and Diophantine equations. Prime factorisations are shown alongside, making it visible why the GCD takes the lowest power of each shared prime and the LCM takes the highest power of every prime.

How it works

Enter two or more whole numbers separated by commas or spaces. The GCD (greatest common divisor, also called HCF) is the largest number that divides all of them; the LCM (lowest common multiple) is the smallest number they all divide into.

Numbers of any size are handled exactly — there is no cut-off at 9,007,199,254,740,991 the way there is in most calculators.

Try:
GCD of 48, 18
6
LCM of 48, 18
144

What that means

Are they coprime?
No — they share a factor of 6
Each divided by the GCD
8 : 3
the same ratio in lowest terms
GCD × LCM
864
equals 48 × 18 for a pair
Numbers read
2

Prime factors

The GCD takes the lowest power of each shared prime; the LCM takes the highest power of every prime.

  • 48 = 2^4 × 3
  • 18 = 2 × 3^2

The Euclidean algorithm, step by step

Repeatedly replace the larger number with the remainder — the last non-zero remainder is the GCD.

StepDivisionRemainder
148 = 2 × 18 + 1212
218 = 1 × 12 + 66
312 = 2 × 6 + 00

Bézout's identity: 48 × -1 + 18 × 3 = 6 — the GCD written as a combination of the two inputs, which is what the extended algorithm gives you.

Frequently asked questions

What is the difference between GCD, HCF and GCF?

Nothing — greatest common divisor, highest common factor and greatest common factor are three names for the same thing: the largest number that divides all your values exactly.

Can I enter more than two numbers?

Yes. Separate them with commas or spaces and both the GCD and the LCM are worked out across the whole set.

What does it mean if the GCD is 1?

The numbers are coprime — they share no factor above 1. Their LCM is then simply their product.

What is Bézout’s identity used for?

It writes the GCD as ax + by using the inputs a and b. Those coefficients are what give you a modular multiplicative inverse, which underpins RSA key generation and solving linear Diophantine equations.

Does it work with very large numbers?

Yes. The arithmetic uses whole numbers of unlimited size, so values well beyond what a standard numeric type can hold stay exact.

Why does it refuse a zero?

Zero makes the LCM zero and the GCD simply the other number. That is mathematically correct but almost always a typo, so it is flagged rather than silently answered.

Related tools