GCD & LCM Calculator

Greatest common divisor and least common multiple of two integers.

GCD & LCM Calculator

Worked example result
Greatest common divisor (GCD)6
Least common multiple (LCM)36
Product (a × b)216

For 12 and 18: the GCD is 6 and the LCM is 36. Check the identity: 6 × 36 = 216, and 12 × 18 = 216.

The greatest common divisor (GCD) is the largest number that divides both of your numbers exactly — for 12 and 18 it is 6. The least common multiple (LCM) is the smallest number that both of them divide into — for 12 and 18 it is 36.

The two are linked by a neat identity: GCD × LCM = a × b. GCD is the key to simplifying fractions, and LCM is how you find a common denominator for adding fractions or work out when repeating events coincide.

The formula

GCD(a, b) × LCM(a, b) = a × b, so LCM = (a × b) ÷ GCD

Worked example

For 12 and 18: the GCD is 6 and the LCM is 36. Check the identity: 6 × 36 = 216, and 12 × 18 = 216.

The example is pre-loaded in the result panel — press Calculate with your own numbers to replace it.

Frequently asked questions

How is GCD calculated quickly for large numbers?

By Euclid's algorithm: repeatedly replace the larger number with the remainder of dividing the two, until the remainder is zero. GCD(48, 18): 48 mod 18 = 12, 18 mod 12 = 6, 12 mod 6 = 0 — so the GCD is 6.

When would I actually use the LCM?

When two cycles must line up: buses leaving every 12 and every 18 minutes coincide every 36 minutes (the LCM). It is also the least common denominator when adding fractions like 1/12 + 1/18.

What if the two numbers share no factors?

Then the GCD is 1 (the numbers are called coprime) and the LCM is simply their product — for example GCD(7, 5) = 1 and LCM(7, 5) = 35.

Category: Math calculators