Number Theory
Basic

LCM from GCD

Least common multiple via the greatest common divisor.

Formula

lcm(a,b)=∣ab∣gcd⁡(a,b)\text{lcm}(a,b) = \frac{|a b|}{\gcd(a,b)}

Variables

a, bIntegers

Example

lcm(12, 18) = 12·18/gcd(12,18) = 216/6 = 36.

How it works

For two integers, the greatest common divisor measures the part they share, while the least common multiple is the smallest number both can divide into. Their prime-factor building blocks split neatly: the gcd takes the overlapping factors, and the lcm takes all factors needed to make both numbers. Because every factor in the product ab is accounted for once in the gcd and once in the lcm, dividing |ab| by gcd(a,b) leaves exactly the smallest common multiple.

When to use it

Use this when you know two integers and want their least common multiple but computing multiples directly would be slow. It is especially useful in number theory, simplifying fractions, and finding common denominators.

Worked example, step by step

Find lcm(8, 30). Step 1: Compute the gcd: gcd(8, 30) = 2. Step 2: Substitute into the formula: lcm(8, 30) = |8 · 30| / 2. Step 3: Multiply: 8 · 30 = 240. Step 4: Divide: 240 / 2 = 120. Final answer: lcm(8, 30) = 120.

Common mistakes to avoid

  • Forgetting the absolute value and getting a negative result when one number is negative
  • Using the formula with gcd(a,b)=0, which only happens when both numbers are 0 and the lcm is not defined in the usual way
  • Swapping gcd and lcm in the formula or dividing by the lcm instead of the gcd

Did You Know?

The product of two numbers always equals their GCD times their LCM — a neat, useful identity.

Share this formula

Reviewed & maintained by the FormulaWon editorial teamLast reviewed September 2026