LCM (Least Common Multiple) Calculator

lcm(a,b) = |a ร— b| / gcd(a,b). Smallest number that both a and b divide evenly.

Inputs

Result

Loading calculatorโ€ฆ
โ€”

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 pairwise

The 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

Example 1
Small inputs
Inputs:
a = 4, b = 6
Output:
|4ยท6| / gcd(4,6) = 24 / 2 = 12
Example 2
Coprime inputs
Inputs:
a = 35, b = 8
Output:
gcd = 1 โ†’ lcm = |35ยท8| / 1 = 280
Example 3
Multiple inputs (pairwise)
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.

Frequently asked

When is LCM useful?+
Adding fractions (1/4 + 1/6: LCM 12 โ†’ 3/12 + 2/12 = 5/12). Schedule synchronization. Cyclic problems.
Why divide by gcd?+
Because aร—b counts the gcd portion twice. Dividing by gcd corrects.
LCM of coprime numbers?+
For coprimes (gcd = 1): LCM = a ร— b. lcm(7, 11) = 77.
Negative numbers?+
LCM is always positive. Calculator takes absolute values.
LCM of 0?+
Undefined (0 has infinite multiples). Calculator excludes 0 inputs.

Related calculators

More tools you might like