Skip to content
Calculator Collection

Least Common Multiple Calculator

Find the least common multiple (LCM) of two positive integers — the smallest number that both divide evenly into. Indispensable for adding fractions with unlike denominators, synchronising periodic events, and scheduling tasks that repeat on different cycles.

Last updated: May 2026

Fill in the required fields to see your result.

Compare with similar

About this calculator

The least common multiple of two positive integers a and b is the smallest positive integer m such that both a | m and b | m. The fastest way to compute it uses the classic identity lcm(a, b) = (a · b) / gcd(a, b), where gcd is the greatest common divisor. This calculator does exactly that: it computes gcd(a, b) via the Euclidean algorithm — repeatedly replacing the larger value with its remainder when divided by the smaller, until one of them becomes 0 — and then divides the product by the gcd. The Euclidean step runs in O(log min(a, b)) time, so even huge inputs resolve in microseconds. Variables: a and b are the two non-negative integers whose LCM you want; both should be ≥ 1 for a meaningful result. Edge cases: lcm(0, n) is conventionally 0 because 0 is a multiple of every integer (but not a useful answer); the formula above breaks when both inputs are 0 because gcd(0, 0) = 0 forces division by zero. For negative inputs the absolute values give the same LCM since multiples are symmetric about 0. The LCM grows quickly when the inputs are coprime (their gcd is 1): lcm(7, 11) = 77, while lcm(12, 18) = 36 — the more factors a and b share, the smaller the LCM. The relationship lcm(a, b) · gcd(a, b) = a · b holds for every pair of positive integers, so once you have one you have both.

How to use

Example 1 — Adding fractions. To add 1/12 + 1/18 you first need a common denominator, which means finding lcm(12, 18). Enter First Number = 12, Second Number = 18. The calculator first finds gcd(12, 18) = 6, then computes (12 × 18) / 6 = 216 / 6 = 36. ✓ So 1/12 = 3/36, 1/18 = 2/36, and the sum is 5/36. Example 2 — Scheduling. Bus route A arrives every 15 minutes and route B every 20 minutes; when do both arrive at the stop together? Enter 15 and 20. gcd(15, 20) = 5, lcm = (15 × 20) / 5 = 60. ✓ Both buses arrive together every 60 minutes. The "next time they coincide" question is exactly what LCM answers, and it generalises to any set of independent periodic events from gear teeth to traffic lights.

Frequently asked questions

What is the difference between LCM and GCD/GCF?

LCM (least common multiple) is the smallest number that both inputs divide into evenly; GCD/GCF (greatest common divisor / greatest common factor) is the largest number that divides both inputs evenly. The two are tightly linked by the identity lcm(a, b) · gcd(a, b) = a · b — knowing one immediately gives the other. As a rule of thumb, LCM is always at least as large as either input, while GCD is always at most as small as either input. When a and b are coprime (share no common factors other than 1), gcd = 1 and lcm = a · b. The two operations come up in different contexts: LCM for combining periodic things or aligning denominators, GCD for simplifying fractions or finding common divisors.

How does the Euclidean algorithm actually work?

The Euclidean algorithm computes gcd(a, b) by repeatedly replacing the pair (a, b) with (b, a mod b) until the second value becomes 0. The remaining first value is the gcd. For example, gcd(48, 18): 48 mod 18 = 12, so the pair becomes (18, 12); 18 mod 12 = 6 → (12, 6); 12 mod 6 = 0 → (6, 0). gcd = 6. Each step uses one division and at least halves the larger number, so the runtime is O(log min(a, b)) — extremely fast even for astronomical inputs. This algorithm is over 2,000 years old (described in Euclid's Elements, Book VII, ~300 BC) and is still optimal in practice. It also generalises to polynomials, Gaussian integers, and other Euclidean domains in abstract algebra.

How do I find the LCM of more than two numbers?

Apply LCM associatively: lcm(a, b, c) = lcm(lcm(a, b), c). For example, lcm(4, 6, 9) = lcm(lcm(4, 6), 9) = lcm(12, 9) = 36. The result does not depend on the order you combine the inputs (LCM is commutative and associative), so any pairing works. For very large lists, you can also factor each input into primes and take the maximum exponent of each prime across the set — for 4 = 2², 6 = 2·3, 9 = 3², the maxima are 2² and 3², giving lcm = 4·9 = 36. The pairwise approach is faster in practice because the Euclidean algorithm is so cheap, but the prime-factorisation view is what most textbooks teach because it makes the structure clear.

What are the most common mistakes people make with LCM?

The first is computing the product a·b and stopping there — that is a common multiple but rarely the least one unless the inputs are coprime. The second is confusing LCM with GCD; people sometimes report the gcd as the lcm or vice versa, which gives wildly different answers (for 12 and 18, gcd = 6 but lcm = 36). The third is trying to compute LCM of fractions or decimals — the standard definition only works for positive integers, though there are generalisations (lcm of fractions = lcm of numerators / gcd of denominators). The fourth is using LCM where GCD is what the problem actually needs — for simplifying a fraction p/q you want gcd(p, q), not the lcm. The fifth is forgetting that lcm(a, 0) is defined as 0 (because 0 is a multiple of every integer), which is mathematically correct but rarely the answer the user wanted.

When should I not use this calculator?

Skip it for non-integer inputs (fractions, decimals, irrational numbers) — the standard LCM is only defined on positive integers, and feeding it 1.5 or √2 gives nothing meaningful. Do not use it when you actually want the greatest common divisor; use a dedicated GCD/GCF calculator instead. It is the wrong tool for LCM of three or more numbers in a single shot — you would have to chain the calculator manually; a multi-input LCM tool is more efficient. Avoid it for finding the smallest fraction with a given denominator constraint (that is a different problem requiring continued fractions or the Stern-Brocot tree). Finally, do not use it for ring-theoretic generalisations (polynomials, Gaussian integers) — those need their own Euclidean algorithm implementations, which standard integer LCM cannot handle.

Sources & references