Skip to content

GCD and LCM calculator

Math & numbers

What do these numbers have in common?

The greatest common divisor and the least common multiple of two to ten whole numbers, with the Euclidean steps.

Result to show first

2 to 10 whole numbers, separated by commas or spaces

Greatest common divisor

12

The greatest common divisor of 24, 36, 60 is 12.

The other answer

Least common multiple
360

Euclidean algorithm

36 = 1 × 24 + 12
12
24 = 2 × 12 + 0
0
gcd(24, 36)
12
60 = 5 × 12 + 0
0
gcd(12, 60)
12

Sponsored Links

The greatest common divisor and the least common multiple of two to ten whole numbers, with the Euclidean steps.

How to use

  1. Type two to ten whole numbers, separated by commas or spaces.
  2. Read the greatest common divisor (GCD) or the least common multiple (LCM), and switch which one comes first.
  3. Open the Euclidean algorithm below to see how the GCD was found, or copy the link to share the same numbers.

Sponsored Links

How it works

The greatest common divisor of some whole numbers is the largest number that divides every one of them without a remainder: the GCD of 24 and 36 is 12. The least common multiple is the smallest positive number that every one of them divides: the LCM of 4 and 6 is 12. The GCD is what you divide by to simplify a fraction, and the LCM is the common denominator for adding fractions.

The Euclidean algorithm finds the GCD by repeated division: divide the larger number by the smaller, then the smaller by the remainder, and so on until the remainder is 0. The last divisor is the GCD. For 48 and 18: 48 = 2 × 18 + 12, then 18 = 1 × 12 + 6, then 12 = 2 × 6 + 0, so the GCD is 6. The LCM then follows from lcm(a, b) = a ÷ gcd(a, b) × b, which gives 48 ÷ 6 × 18 = 144.

For more than two numbers the answer is built pair by pair: gcd(a, b, c) = gcd(gcd(a, b), c), and the same for the LCM. The signs of numbers are ignored. The GCD of 0 and a number is that number, gcd(0, 0) is defined as 0, and the LCM is 0 whenever one of the numbers is 0. Calculations are exact, for numbers of up to 40 digits.

Worked example

What are the GCD and LCM of 12 and 18?

  1. Divide with remainder: 18 = 1 × 12 + 6.
  2. The last nonzero divisor is 6.

GCD = 6; LCM = 12 ÷ 6 × 18 = 36.

Frequently asked questions

What is the difference between GCD and LCM?

The GCD is the biggest number that fits into all of the numbers, so it is never larger than the smallest of them. The LCM is the smallest number that all of them fit into, so it is never smaller than the largest of them.

What does it mean if the GCD is 1?

The numbers share no factor except 1, so they are called coprime. 8 and 15 are coprime even though neither is prime. The LCM of two coprime numbers is simply their product.

Is GCD the same as GCF or HCF?

Yes. Greatest common factor, highest common factor and greatest common divisor are different names for the same number.

How do I use the GCD to simplify a fraction?

Divide the top and the bottom by their GCD. For 18/48 the GCD is 6, so the fraction simplifies to 3/8.

Can I enter negative numbers?

Yes. The signs are ignored, so negative numbers give the same divisors and multiples as their positive counterparts.

Sponsored Links

Sponsored Links