The GCD (greatest common divisor) is the largest integer that divides all the given numbers. The LCM (least common multiple) is the smallest positive integer that is a multiple of all of them. Both show up in fractions, repeating-event problems and splitting into equal parts.

Method 1: prime factorization

Break each number into prime factors.

  • GCD: product of the shared primes, each with the smallest exponent.
  • LCM: product of all primes that appear, each with the largest exponent.

Worked example: 12 and 18

  1. 12=22312 = 2^2 \cdot 3 and 18=23218 = 2 \cdot 3^2.
  2. gcd=2131=6\text{gcd} = 2^1 \cdot 3^1 = 6.
  3. lcm=2232=36\text{lcm} = 2^2 \cdot 3^2 = 36.
  4. Check: 636=216=12186 \cdot 36 = 216 = 12 \cdot 18.

Method 2: the ladder (simultaneous division)

Divide all the numbers by primes in order, in one table, until every entry is 1. The product of all divisors is the LCM; the product of the divisors that divided every number at once is the GCD.

Worked example: 12, 18 and 30

NumbersPrime divisor
12, 18, 302 (divides all)
6, 9, 152
3, 9, 153 (divides all)
1, 3, 53
1, 1, 55
1, 1, 1done
  1. lcm=22335=180\text{lcm} = 2 \cdot 2 \cdot 3 \cdot 3 \cdot 5 = 180.
  2. gcd=23=6\text{gcd} = 2 \cdot 3 = 6.

Method 3: the Euclidean algorithm

For large numbers, factoring is slow. Euclid uses the fact that gcd(a,b)=gcd(b,r)\text{gcd}(a, b) = \text{gcd}(b, r), where rr is the remainder of a÷ba \div b. Repeat until the remainder is zero; the last divisor is the GCD.

Worked example: gcd(84, 36)

  1. 84=236+1284 = 2 \cdot 36 + 12.
  2. 36=312+036 = 3 \cdot 12 + 0.
  3. The remainder is zero: gcd(84,36)=12\text{gcd}(84, 36) = 12.

Shortcut: the LCM from the GCD

For two positive numbers:

lcm(a,b)=abgcd(a,b)\text{lcm}(a, b) = \frac{a \cdot b}{\text{gcd}(a, b)}

With the previous example: lcm(84,36)=843612=736=252\text{lcm}(84, 36) = \dfrac{84 \cdot 36}{12} = 7 \cdot 36 = 252.

Typical word problems

Worked example: two buses leave together at 8:00, one every 12 minutes and the other every 18 minutes. When do they leave together again?

  1. Repeating events that coincide: LCM.
  2. lcm(12,18)=36\text{lcm}(12, 18) = 36.
  3. They leave together again at 8:36.

Worked example: ribbons of 84 cm and 36 cm must be cut into equal pieces, as long as possible, with nothing left over. How long is each piece, and how many pieces are there?

  1. Largest equal part that divides both: GCD.
  2. gcd(84,36)=12\text{gcd}(84, 36) = 12 cm.
  3. Pieces: 84÷12+36÷12=7+3=1084 \div 12 + 36 \div 12 = 7 + 3 = 10.

Common mistakes

  1. Including primes in the GCD that are not shared by every number.
  2. Using lcmgcd=ab\text{lcm} \cdot \text{gcd} = a \cdot b with three or more numbers.
  3. Mixing up which one the problem asks for: coincidence calls for the LCM; equal parts call for the GCD.

Frequently asked questions

When do word problems call for the LCM and when for the GCD?

The LCM appears when events repeat and you want to know when they coincide. The GCD appears when you split quantities into equal parts of the largest possible size.

What is the GCD of two coprime numbers?

It is 1, by definition. In that case the LCM is their product, as in lcm(8, 15) = 120.

Does lcm · gcd = a · b work for three numbers?

Not in general. For 2, 4 and 8, the LCM is 8 and the GCD is 2, with product 16, but 2 · 4 · 8 = 64.