LCM (Least Common Multiple) Calculator
lcm(a,b) = |a ร b| / gcd(a,b). Smallest number that both a and b divide evenly.
Result
How to use this calculator
- Enter 2-4 positive integers.
- Leave optional fields at 0 to ignore.
About this calculator
The LCM (least common multiple) is the smallest positive integer that is a multiple of all the inputs. Computed via gcd: lcm(a,b) = |a ร b| / gcd(a,b). For more than 2: associative โ lcm(a,b,c) = lcm(lcm(a,b),c). Common use: adding fractions (find common denominator), scheduling cycles that synchronize, music time signatures. lcm(12, 18) = 36 โ same as 12 ร 3 = 36 = 18 ร 2.
How it works โ the formula
lcm(a, b) = (|a ยท b|) / gcd(a, b)
lcm(aโ, aโ, โฆ, aโ) โ apply pairwiseThe least common multiple of two integers is the smallest positive integer that both divide. The product-quotient identity above lets any LCM calculation reduce to a GCD calculation, which Euclid's algorithm handles in O(log min(a,b)). For more than two integers, the LCM is associative and can be computed pairwise: lcm(a,b,c) = lcm(lcm(a,b), c).
Worked examples
- Inputs:
- a = 4, b = 6
- Output:
- |4ยท6| / gcd(4,6) = 24 / 2 = 12
- Inputs:
- a = 35, b = 8
- Output:
- gcd = 1 โ lcm = |35ยท8| / 1 = 280
- Inputs:
- lcm(4, 6, 8)
- Output:
- lcm(4,6) = 12; lcm(12, 8) = 24
Limitations
- lcm(a, 0) = 0 by convention (zero is a multiple of every integer).
- Computes positive LCM; sign of inputs is ignored via the |ยท| in the identity.
- For very large integers (above 2โตยณ), use BigInt to avoid floating-point precision loss.
- For real or polynomial domains, generalise via the appropriate Euclidean ring rather than this formula.
Implementation reduces to GCD via the product identity; result exact for inputs within the safe-integer range.