GCD and LCM

Greatest common divisor · least common multiple

GCD and LCM — illustration
GCD
6
greatest common divisor
LCM
180
least common multiple
Prime factorization
12 = 2² · 3
18 = 2 · 3²
30 = 2 · 3 · 5

The GCD is the largest number dividing all of the inputs, the LCM — the smallest divisible by all of them. Relationship: GCD(a,b)·LCM(a,b) = a·b.

The GCD (greatest common divisor) is the largest number that divides all of the inputs with no remainder, and the LCM (least common multiple) — the smallest number divisible by each of them.

The GCD is found quickly with the Euclidean algorithm, and the LCM from the relationship:

LCM(a,b)=a⋅bGCD(a,b)\text{LCM}(a,b)=\frac{a\cdot b}{\text{GCD}(a,b)}

The calculator accepts any number of values and also shows their prime factorization — because the GCD is the product of common factors, while the LCM covers all factors raised to their highest powers.

Examples

GCD and LCM of 12, 18, 30
→ GCD = 6, LCM = 180
GCD(8, 12)
→ = 4 (8 = 2³, 12 = 2²·3, common 2²)

Frequently asked questions

What is the LCM used for?+

Mainly for adding fractions (a common denominator) and for "how often will two cyclic events coincide" problems — e.g. buses leaving every 12 and 18 minutes coincide every LCM = 36 minutes.

How is the GCD related to the LCM?+

The product of the GCD and LCM of two numbers equals the product of those numbers: GCD(a,b)·LCM(a,b) = a·b. Knowing one, you can easily find the other.

Found this calculator useful? Share it.

It's free — send it to a friend who's revising.

Teaching? Embed this calculator on your site.

Free widget — paste it on your school site, blog or notes. It links to the full version.

Teaching a class or tutoring? Guide students in NexTutor →