Least Common Multiple

Find the least common multiple (LCM) of two or more numbers

About This Tool

Enter two or more integers, separated by spaces or commas. The tool returns their least common multiple along with the GCD it computed along the way.

Reach for it when adding fractions with different denominators, working out gear ratios that mesh evenly, or solving Chinese Remainder Theorem problems. The implementation uses LCM(a,b) = |a·b| / GCD(a,b), iterated for more than two inputs — exact integer math, no floating-point drift.

Negatives and zero are handled (LCM of any set containing zero is zero; LCM treats negatives as their absolute values). Very large inputs use BigInt, so 20-digit numbers don't overflow.

LCM is computed via the GCD relationship: LCM(a, b) = |a · b| / GCD(a, b). The GCD itself comes from Euclid's algorithm: GCD(a, b) = GCD(b, a mod b), with GCD(a, 0) = |a|. Iterating until the second argument hits zero terminates in at most O(log(min(a,b))) steps — extremely fast. For more than two inputs, LCM is associative: LCM(a, b, c) = LCM(LCM(a, b), c), and so on. The tool processes inputs left-to-right in this fold.

Worked example. Inputs: 12, 18, 30. GCD(12, 18) = 6 (since 18 = 12·1 + 6, 12 = 6·2 + 0). LCM(12, 18) = 12·18/6 = 36. GCD(36, 30) = 6 (36 = 30·1 + 6, 30 = 6·5 + 0). LCM(36, 30) = 36·30/6 = 180. So LCM(12, 18, 30) = 180. Verify: 180 = 12 × 15 = 18 × 10 = 30 × 6. Yes, and no smaller positive integer is divisible by all three.

Applications. Adding fractions: LCM of denominators is the common denominator. 1/12 + 1/18 + 1/30 → all over 180 → 15/180 + 10/180 + 6/180 = 31/180. Gear ratios that mesh evenly: a 12-tooth and 18-tooth gear realign every LCM(12,18) = 36 teeth. Periodic events: if event A happens every 12 days and event B every 18 days, they coincide every 36 days. Chinese Remainder Theorem solutions involve pairwise LCMs of moduli to determine when systems of congruences have unique solutions.

Edge cases handled by the tool. LCM(a, 0) = 0 for any a — the only positive multiple of 0 is 0 itself, vacuously. LCM(0, 0) = 0 by convention. Negative inputs are treated by absolute value, since LCM is conventionally defined for positive integers. The tool warns if all inputs are 0.

Very large inputs use BigInt for exact arithmetic. JavaScript's Number type loses integer precision above 2^53. With BigInt, LCM of 20-digit numbers is computed exactly and in microseconds. The display shows scientific notation for results above 10^15 with a copy button for the full integer string. For genuinely massive numbers (cryptographic primes, factorial-derived inputs), the calculation can take measurable time — the tool reports the elapsed milliseconds so you can see when you've crossed the line into "slow."

The about text and FAQ on this page were drafted with AI assistance and reviewed by a member of the Coherence Daddy team before publishing. See our Content Policy for editorial standards.

Frequently Asked Questions