GCD and LCM Calculator

Find the greatest common divisor (HCF) and least common multiple of two or more whole numbers, with every Euclidean step shown.

Numbers

Whole number, up to 9,007,199,254,740,991.

Whole number, up to 9,007,199,254,740,991.

Up to 18 extra numbers, separated by spaces or commas. Each number: 1 to 9,007,199,254,740,991.

Results

Greatest common divisor
12
GCD(48, 180) = 12
Least common multiple
720
LCM(48, 180)
Coprime
No
They share the factor 12
Common divisors
1, 2, 3, 4, 6, 12
6 common divisors

Euclidean algorithm steps

Divide the larger number by the smaller, then repeat with the divisor and the remainder:

  1. 180 = 48 × 3 + 36
  2. 48 = 36 × 1 + 12
  3. 36 = 12 × 3 + 0

The last non-zero remainder is 12, so GCD(48, 180) = 12.

How the Euclidean algorithm works

Euclid described this method in Book VII of the Elements, around 300 BC. It is still one of the fastest ways to find a GCD: the numbers at least halve every two steps.

Given two positive whole numbers aa and bb with a≥ba \ge b:

  1. Find the quotient qq and remainder rr so that a=b⋅q+ra = b \cdot q + r, where 0≤r<b0 \le r < b.
  2. If r=0r = 0, stop: gcd⁡(a,b)=b\gcd(a, b) = b.
  3. Otherwise replace aa with bb and bb with rr, and repeat.

For more than two numbers, apply it in turn:

gcd⁡(a,b,c)=gcd⁡(gcd⁡(a,b),c)\gcd(a, b, c) = \gcd(\gcd(a, b), c)

The LCM follows from the GCD:

lcm⁡(a,b)=a×bgcd⁡(a,b)\operatorname{lcm}(a, b) = \frac{a \times b}{\gcd(a, b)}

Worked example: GCD of 48 and 180

These are the calculator's default numbers, so the result above matches each line here.

Euclidean steps for 180 and 48
StepDivision a = b × q + rRemainder
Step 1180 = 48 × 3 + 3636
Step 248 = 36 × 1 + 1212
Step 336 = 12 × 3 + 00 (stop)

The last non-zero remainder is 12, so GCD(48, 180) = 12. The LCM is 48 × 180 ÷ 12 = 720.

Where the GCD is used

  • Simplifying fractions: divide the top and bottom by their GCD. 48/180 becomes 4/15.
  • Equal groups: the largest number of equal teams you can make from 48 boys and 180 girls, with no one left over, is the GCD: 12 teams.
  • Tiling: the largest square tile that fits a 48 cm by 180 cm area exactly is 12 cm.
  • Repeating events: two buses leaving every 48 and 180 minutes leave together again after the LCM, 720 minutes.

Frequently asked questions

How does the Euclidean algorithm find the GCD?
It uses the fact that the GCD of two numbers does not change when the larger number is replaced by its remainder after dividing by the smaller one. Divide a by b to get a = b × q + r, then repeat with b and r. When the remainder reaches 0, the last non-zero remainder is the GCD.
What does it mean if two numbers are coprime?
Two whole numbers are coprime (or relatively prime) when their GCD is 1. They share no positive factor other than 1. For example, 8 and 15 are coprime even though neither is prime.
What is the relationship between GCD and LCM?
For any two positive whole numbers, a × b = GCD(a, b) × LCM(a, b). So once you know the GCD, the LCM is (a × b) ÷ GCD(a, b). This identity holds for two numbers only, not for three or more.
What is the GCD of two prime numbers?
A prime has no divisors other than 1 and itself, so two different primes (such as 13 and 29) always have a GCD of exactly 1.
Can the GCD be larger than either number?
No. A common divisor must divide both numbers exactly, so GCD(a, b) can never exceed the smaller number. It equals the smaller number only when the smaller divides the larger, for example GCD(6, 24) = 6.
Is HCF the same as GCD?
Yes. Highest common factor (HCF), greatest common divisor (GCD) and greatest common factor (GCF) are three names for the same number. HCF is the usual term in Indian and British schools.
Esc