LCM from GCD
Least common multiple via the greatest common divisor.
Formula
Variables
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
More in Number Theory
View allEuclidean Algorithm
BasicRecursively finds the greatest common divisor.
Modular Congruence
Basica and b have the same remainder when divided by m.
Fermat's Little Theorem
AdvancedHolds when p is prime and gcd(a,p)=1.
Euler's Totient
AdvancedCounts integers up to n coprime to n.
Prime Number Theorem
AdvancedApproximates the number of primes below x.
Sum of First n Integers
BasicClosed form for the sum of the first n natural numbers.