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.
What that means
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.
| Step | Division | Remainder |
|---|---|---|
| 1 | 48 = 2 × 18 + 12 | 12 |
| 2 | 18 = 1 × 12 + 6 | 6 |
| 3 | 12 = 2 × 6 + 0 | 0 |
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
Prime Factorization Calculator
Break any whole number into its prime factors, exactly, even well beyond the usual size limits.
Big Number Calculator
Exact arithmetic on whole numbers of any length — far past the point where ordinary calculators start rounding.
Fraction Calculator
Add, subtract, multiply and divide fractions and mixed numbers exactly, with the working shown.