Joy of Tools

GCD and LCM calculator

Type two or more whole numbers. The GCD, the LCM and the working update as you type.

What you enter stays on this page and is not sent anywhere.

Type whole numbers of 1 or more. With a single number you get its prime factors and divisors.

Paste a list such as 12, 18, 30 and it is split into boxes. Up to 10 numbers.

GCD
6
LCM
36

6 is the largest number that divides all of them, and 36 is the smallest number they all divide into.

12 × 18 = 6 × 36 = 216

How it is found

Divide both numbers by a prime that goes into both, until no prime does.

21218
369
23
GCD
Multiply the primes on the left that divided every number: 2 × 3 = 6
LCM
Multiply every prime on the left and every number on the bottom row: 2 × 3 × 2 × 3 = 36

Common divisors and multiples

The common divisors are the divisors of the GCD 6; the common multiples are the multiples of the LCM 36.

4 common divisors
1, 2, 3, 6
Common multiples, smallest first
36, 72, 108, 144, 180, …

Prime factors and divisors of each number

12 = 2² × 3

6 divisors = (2+1) × (1+1)

1, 2, 3, 4, 6, 12

Show the division by primes
212
26
33
1

Divide by the smallest prime until the quotient is 1, then multiply the primes on the left.

18 = 2 × 3²

6 divisors = (1+1) × (2+1)

1, 2, 3, 6, 9, 18

Show the division by primes
218
39
33
1

Divide by the smallest prime until the quotient is 1, then multiply the primes on the left.

How to use it

  1. Type the numbers, one per box, or paste a list such as 12, 18, 30.
  2. Read the greatest common divisor and the least common multiple.
  3. Pick the division ladder, prime factors or Euclid's algorithm to see how they are found.

Questions

How do you find the GCD and LCM from prime factors?

Write each number as a product of primes. The GCD takes every shared prime with its smallest power; the LCM takes every prime that appears with its largest power. 12 = 2² × 3 and 18 = 2 × 3², so the GCD is 2 × 3 = 6 and the LCM is 2² × 3² = 36.

What is Euclid's algorithm?

Divide the larger number by the smaller and keep dividing the last divisor by the remainder. When the remainder is 0, the last divisor is the GCD. It works for numbers of any size, which is why this page uses it for numbers above one trillion.

Why is GCD × LCM equal to the product of two numbers?

For two numbers, each prime goes once into the GCD with its smaller power and once into the LCM with its larger power, so together they hold exactly the primes of both numbers. This holds only for two numbers, not three or more.

What does it mean when the GCD is 1?

The numbers share no prime factor, so they are called coprime. With three or more numbers a GCD of 1 does not mean every pair is coprime: 6, 10 and 15 have a GCD of 1, but 6 and 10 share the factor 2.

More tools