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…
—

General calculation reads

Amazon affiliate

As an Amazon Associate we may earn from qualifying purchases. This does not add cost for you.

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

Hand-picked tools that pair well with this one — same audience, same intent.