About the GCD and LCM Calculator
The greatest common divisor (GCD) – also called the greatest common factor (GCF) or highest common factor (HCF) – is the largest number that divides all the given numbers. The least common multiple (LCM) is the smallest number that all of them divide into. This calculator factors every number into primes and compares the exponents in a table, so you can follow each step.
It works with two, three or up to 20 numbers at once, and shows even very large LCMs as exact integers.
How to use
- Enter two or more whole numbers separated by commas or spaces, e.g. 12, 18, 30.
- The GCD and LCM appear at the top right away.
- Scroll down for the prime factorization of each number, the exponent table and the final formulas.
- The common factors are simply all divisors of the GCD.
How to find the GCD and LCM by prime factorization
Example with 12, 18 and 30:
- Factor each number: 12 = 2² × 3, 18 = 2 × 3², 30 = 2 × 3 × 5
- GCD: multiply the primes that appear in every number (2 and 3), each with its smallest exponent → 2 × 3 = 6
- LCM: multiply all primes that appear (2, 3, 5), each with its largest exponent → 2² × 3² × 5 = 180
Euclidean algorithm and useful facts
- Euclidean algorithm: if r is the remainder of a ÷ b, then gcd(a, b) = gcd(b, r). Example: gcd(84, 36) → gcd(36, 12) → gcd(12, 0) = 12
- For two numbers, a × b = GCD × LCM always holds. This does not work for three or more numbers.
- Two numbers whose GCD is 1 are coprime (relatively prime); their LCM is their product. Example: 8 and 15 → 120
Everyday examples
- GCD: cutting a 24 × 36 inch board into the largest equal squares with no waste → 12-inch squares
- LCM: one bus leaves every 6 minutes and another every 8 minutes; after leaving together they meet again in 24 minutes
- LCM: adding fractions – the least common denominator of 1/4 and 1/6 is LCM(4, 6) = 12
FAQ
How many numbers can I enter?
Up to 20 numbers, each up to one trillion (10¹²). The LCM is always computed as an exact integer, however large it gets.
Can I use 0 or negative numbers?
GCD and LCM are usually defined for positive integers, so only whole numbers of 1 or more are accepted. For negative numbers, drop the sign – the result is the same.
What is the difference between GCD, GCF and HCF?
Nothing – they are different names for the same thing: the greatest common divisor, greatest common factor or highest common factor.
How are common factors related to the GCD?
Every common factor divides the GCD. So listing the divisors of the GCD gives you all the common factors.