GCD–LCM Identity

Also known as gcd times lcm · product of gcd and lcm · ab = gcd lcm · lcm from gcd

a⋅b=gcd⁡(a,b)⋅lcm⁡(a,b)a \cdot b = \gcd(a,b) \cdot \operatorname{lcm}(a,b)

Units aren’t used in this calculation — every value is a plain number.

Worked example: 12 and 18, gcd 6 → lcm 36 — press Try an example to run it live, then adjust anything.

Enter your known values, leave one input blank, and solves for the missing one. Tap a variable’s symbol to see what it means, with a typical value.

Learning zone

GCD–LCM Identity explained

gabl

Two numbers, their greatest common divisor, their least common multiple: multiply the first pair and you get the same answer as multiplying the second. Take 12 and 18. The gcd is 6, the lcm is 36, and 12×18=216=6×3612 \times 18 = 216 = 6 \times 36. It works because of how prime factorisations line up. Write 12=22⋅312 = 2^2 \cdot 3 and 18=2⋅3218 = 2 \cdot 3^2; for each prime the gcd takes the smaller exponent and the lcm takes the larger, so between them they take both. Multiplying gcd by lcm therefore recovers every prime factor exactly as many times as the original product had it.

The practical use is that the lcm is the expensive one to compute and the gcd is cheap. Euclid's algorithm finds gcd(12, 18) in two steps and never factors anything, so the usual route to a least common multiple is not to factor at all — find the gcd, then divide the product by it. Every library that offers lcm does it this way underneath, and it is why lcm has no algorithm of its own.

Now the trap, because this formula is more willing than the mathematics is. Enter b = 18, g = 5, l = 36 and the solver dutifully returns a = 10 — the algebra is fine, 5×36/18=105 \times 36 / 18 = 10. But gcd(10, 18) is 2, not 5, so no pair of numbers has those properties and the answer describes nothing. Three of the four values cannot be chosen freely: the gcd must divide both numbers, and it must divide the lcm too. If you are solving for a missing number rather than checking a known pair, verify the result the other way round before trusting it.

GCD–LCM Identity formula

a⋅b=gcd⁡(a,b)⋅lcm⁡(a,b)a \cdot b = \gcd(a,b) \cdot \operatorname{lcm}(a,b)
Where
  • aa= First number
  • bb= Second number
  • gg= Greatest common divisor
  • ll= Least common multiple

Missing one of these? Work it out first, then come back