Arithmetic, Algebra & Number Theory Number Theory, Divisors & Number Systems Fundamental theorem of arithmetic; Euclidean algorithm

Least Common Multiple (LCM) Calculator

Enter two, three or four whole numbers and this calculator returns their least common multiple — the smallest positive number that every one of them divides exactly. It works the problem two ways: by the identity lcm(a, b) = a·b ÷ gcd(a, b) folded across the list, and by prime factorization, taking the highest power of each prime. You also get the matching GCD, how many copies of each number it takes to reach the LCM, and a table of the next several common multiples. Leave the third and fourth fields at zero if you only need a pair.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
First integerAny whole number. A minus sign is ignored, because the least common multiple is defined as a positive value.8
Second integerThe second whole number — for a common denominator, this is your other denominator.12
Third integerLeave at 0 if you only have two numbers; zeros are treated as unused fields.0
Fourth integerLeave at 0 if you only have two or three numbers.0

It returns

  • Least common multiple — The smallest positive number that every integer you entered divides exactly.
  • LCM as a product of primes
  • Greatest common divisor — The other half of the pair: lcm(a, b) × gcd(a, b) = a × b.
  • Copies of the first number — How many times the first number goes into the LCM.
  • Copies of the second number — How many times the second number goes into the LCM.

The formula

lcm(a,b)=|ab|gcd(a,b)
lcm=ppmax(e1,e2,)

In plain text: lcm(a, b) = |a · b| / gcd(a, b); lcm(a, b, c) = lcm(lcm(a, b), c)

  • aFirst integer (integer)
  • bSecond integer (integer)
  • gcd(a, b)Greatest common divisor, found by the Euclidean algorithm (integer)
  • lcm(a, b)Least common multiple — the smallest positive number both divide (integer)

Divide before you multiply: a ÷ gcd(a, b) is always a whole number, and doing the division first keeps the intermediate value small enough to stay exact. For three or more numbers, fold the pair rule left to right.

Updated Category Number Theory, Divisors & Number Systems Verified against published test cases Reading time 12 min

What the least common multiple is

The least common multiple of a set of whole numbers is the smallest positive number that every one of them divides exactly. Multiples of 8 run 8, 16, 24, 32, 40, 48, …; multiples of 12 run 12, 24, 36, 48, 60, …. The values appearing in both lists are 24, 48, 72, … and the smallest is 24. That is lcm(8, 12).

Look at what the shared list turned out to be: 24, 48, 72 — every multiple of 24, and nothing else. That is the structural fact worth carrying away. The common multiples of a set are exactly the multiples of their least common multiple. There is never a common multiple sitting between two of them, which is why the table this calculator prints contains all of them in order.

You need an LCM whenever two or more repeating cycles have to line up. Two buses leave a stop every 8 and 12 minutes: they leave together every 24 minutes. Two gears with 8 and 12 teeth return to their starting alignment after 24 tooth-engagements — three turns of the small gear, two of the large. A maintenance task done every 8 weeks and another every 12 weeks coincide every 24 weeks.

The most common school use is the least common denominator. To add ⅛ + 1/12 you need a denominator both eighths and twelfths fit into, and 24 is the smallest: 3/24 + 2/24 = 5/24. Any common denominator works, but the least one keeps the arithmetic small and usually leaves the answer already in lowest terms. The adding and subtracting fractions calculator does that step automatically.

Why lcm(a, b) = a·b ÷ gcd(a, b)

The product of two numbers is always a common multiple — 8 × 12 = 96 is divisible by both — but it is usually not the least one, because the shared factors get counted twice. The greatest common divisor measures exactly that double-counting, so dividing it out repairs the overshoot: 96 ÷ gcd(8, 12) = 96 ÷ 4 = 24.

The prime-exponent view makes the reason plain. Write each number as a product of prime powers. A number is a multiple of 8 = 2³ precisely when it contains at least three factors of 2; it is a multiple of 12 = 2²·3 precisely when it contains at least two factors of 2 and one of 3. To satisfy both at once with nothing to spare, take each prime to the highest power any of the numbers demands: 2³ · 3 = 24. Take the lowest power instead and you get the greatest common factor. Since min(e₁, e₂) + max(e₁, e₂) = e₁ + e₂ for every prime, multiplying the GCF by the LCM reconstructs the product a·b — which is the identity above, derived rather than memorised.

Two practical points follow. First, divide before you multiply. Computing a ÷ gcd first and then multiplying by b gives the same answer while keeping the intermediate number as small as possible, which matters when the values are large. Second, the identity is a two-number rule. For three or more numbers there is no formula relating the LCM to the GCD and the product; you fold instead, lcm(a, b, c) = lcm(lcm(a, b), c), which is valid because the common multiples of a and b are precisely the multiples of lcm(a, b).

The Euclidean algorithm supplies the GCD in a handful of divisions no matter how large the inputs, which is why this route is far faster than factoring. Factoring is still the better way to understand an answer, and it is what the prime-power table under the results shows.

Worked example: lcm(8, 12) and lcm(12, 18, 24)

Two numbers, by the GCD identity.

  1. Find the GCD with Euclid: 12 ÷ 8 = 1 remainder 4, then 8 ÷ 4 = 2 remainder 0. The last non-zero remainder is 4.
  2. Divide first: 8 ÷ 4 = 2.
  3. Multiply: 2 × 12 = 24.
  4. Check the product rule: gcd × lcm = 4 × 24 = 96, and 8 × 12 = 96. ✓
  5. Copies needed: 24 ÷ 8 = 3 of the first number, 24 ÷ 12 = 2 of the second.

The same answer by prime factorization. 8 = 2³ and 12 = 2² × 3. The primes involved are 2 and 3. The highest power of 2 is 2³ (from the 8); the highest power of 3 is 3¹ (from the 12). So the LCM is 2³ × 3 = 8 × 3 = 24.

Three numbers, by folding. Take 12, 18 and 24.

  1. lcm(12, 18): gcd(12, 18) = 6, so 12 ÷ 6 = 2, and 2 × 18 = 36.
  2. Now fold in 24: gcd(36, 24) = 12, so 36 ÷ 12 = 3, and 3 × 24 = 72.
  3. Confirm by exponents: 12 = 2²·3, 18 = 2·3², 24 = 2³·3. Highest power of 2 is 2³; highest power of 3 is 3². So the LCM is 8 × 9 = 72. ✓

Now see why the two-number shortcut must not be used here. The GCD of all three is 6 and the LCM is 72, so their product is 432 — while 12 × 18 × 24 = 5,184. The identity gcd × lcm = product simply does not extend past a pair.

How to read the result

An LCM equal to the product means the numbers are coprime. lcm(4, 9) = 36 = 4 × 9 because they share no prime. Whenever the LCM comes out smaller than the product, the shortfall is exactly the GCD's worth of duplication: the ratio product ÷ LCM is the GCD for a pair.

An LCM equal to the largest number entered means that number is a multiple of all the others. lcm(3, 6, 12) = 12 tells you 12 is already divisible by 3 and 6, so no new denominator is needed. In fraction work that is the happy case: one of the denominators already serves.

The copies figures are the ones to read for scheduling and gearing. If the LCM is 24 and your first cycle is 8 units long, it takes three repeats of that cycle to reach the meeting point. Those two counts are always coprime for a pair of numbers, because any shared factor between them would mean you had passed a smaller common multiple on the way.

Watch the size. The LCM grows fast: lcm(1, 2, 3, …, 10) = 2,520 and lcm(1, 2, 3, …, 20) = 232,792,560. If you are choosing a common denominator for four or five fractions, the least one can still be large, and it is sometimes easier to work with a convenient common denominator and simplify at the end.

Finally, the reported GCD is not decoration. Reading both numbers together tells you the shape of the relationship: a large GCD and a small LCM means the numbers overlap heavily; a GCD of 1 and an LCM equal to the product means they are structurally independent.

LCM, GCD and product for standard pairs

For any pair of positive integers, GCD × LCM equals the product. Every row satisfies it, which is the quickest way to check an LCM by hand.
aba in primesb in primesGCDLCMa × b
462·321224
8122²·342496
6212·33·7342126
9413636
15203·52²·5560300
14352·75·7770490
24362³·32²·3²1272864
100752²·5²3·5²253007,500

Check any row: 25 × 300 = 7,500, which is 100 × 75. Rows where the LCM equals the product (9 and 4) are exactly the coprime ones.

Zero is a special case, and this calculator treats it as “unused”

Strictly, every integer divides 0, so 0 is a common multiple of any set and the definition gives lcm(a, 0) = 0. That is mathematically correct and practically useless: one empty field would zero out every answer. This calculator therefore treats a field left at 0 as an unused slot and computes the LCM of the non-zero entries only. If every field is 0 the result is left blank rather than reported as 0, because there is nothing to compute.

Mistakes that produce the wrong LCM

  • Multiplying the numbers together and stopping. The product is always a common multiple but is the least one only when the numbers are coprime. 6 × 21 = 126, while the LCM is 42.
  • Taking the lowest exponent instead of the highest. That gives the greatest common factor. The LCM needs the highest power of every prime that appears anywhere.
  • Dropping a prime that only one number has. 5 appears in 15 but not in 4; it still has to appear in lcm(15, 4) = 60, because the answer must be a multiple of 15.
  • Applying gcd × lcm = product to three or more numbers. It holds for a pair only. For 12, 18 and 24 the GCD is 6 and the LCM is 72, whose product is 432, nowhere near 5,184.
  • Multiplying before dividing on large inputs. a × b can overflow exact integer range even when the LCM does not. Compute a ÷ gcd first, then multiply.
  • Assuming the least common denominator must be the LCM. It is the smallest workable denominator, but any common multiple works. If the LCM is awkward, a larger one still gives a correct answer that you can simplify at the end.
  • Using an LCM on decimals. Multiples are defined for integers. Scale 0.4 and 0.6 to 4 and 6, take lcm = 12, then scale back to 1.2.

Where the LCM sits among related tools

The LCM and the GCF are mirror images built from the same prime exponents — highest powers for one, lowest for the other — and they divide the work of fraction arithmetic between them. Use the GCF calculator to simplify a fraction, and the LCM to combine fractions over a common denominator. To see the underlying prime powers for a single number, use the prime factorization calculator; to list every divisor, the factors of a number calculator.

Outside the classroom the LCM is the standard answer to “when do these cycles coincide?”. Gear trains use it to find the hunting-tooth period. Production planners use it to size a repeating schedule that contains a whole number of every sub-cycle. In modular arithmetic it appears as the order of a combined system, and the Chinese remainder theorem builds its solution modulo the LCM of the moduli — a topic the modulo calculator introduces.

Two limits are worth stating. This page works with values up to 10¹², and suppresses the LCM if the answer would exceed 2⁵³, the largest integer a browser holds exactly; beyond that you need arbitrary-precision arithmetic. And the LCM is defined for integers, so any real-world quantity has to be expressed in a common whole-number unit — tenths, minutes, teeth — before the concept applies at all.

Key terms

Multiple
A number obtained by multiplying an integer by a whole number. The multiples of 8 are 8, 16, 24, 32 and so on; a number is never smaller than the number it is a multiple of (except 0).
Common multiple
A number that every member of the set divides exactly. All of them are multiples of the least common multiple.
Least common denominator (LCD)
The least common multiple of the denominators of a set of fractions — the smallest denominator you can rewrite them all over.
Coprime
Two integers whose greatest common divisor is 1. Exactly the case where the LCM equals the product.
Fundamental theorem of arithmetic
Every integer above 1 factors into primes in exactly one way. It is what makes the max-exponent rule a valid definition.

Frequently asked questions

What is the difference between the LCM and the GCF?

The GCF is the largest number that divides into your numbers; the LCM is the smallest number your numbers divide into. In prime terms the GCF takes the lowest power of each shared prime and the LCM takes the highest power of every prime that appears. For a pair they are linked exactly: GCF × LCM = the product of the two numbers. Use the GCF to simplify a fraction and the LCM to find a common denominator.

How do I find the least common multiple of three numbers?

Fold two at a time: lcm(a, b, c) = lcm(lcm(a, b), c). For 12, 18 and 24, lcm(12, 18) = 36, then lcm(36, 24) = 72. The prime-exponent method handles all three at once — take the highest power of each prime across the whole list — and gives the same 2³ × 3² = 72. What you must not do is divide the product of all three by their overall GCD; that shortcut is valid for a pair only.

Is the least common multiple always bigger than the numbers?

It is never smaller than the largest number you entered, and it equals that largest number whenever the largest is already a multiple of all the others — lcm(3, 6, 12) = 12. At the other extreme, when the numbers are coprime the LCM is their full product. So the answer always lands between the largest entry and the product of the entries.

Why does the calculator ignore fields left at zero?

Because the strict definition would make the answer useless. Every integer divides 0, so 0 counts as a common multiple of anything and lcm(a, 0) = 0 — meaning one blank field would collapse your result to zero. Treating an empty field as unused is the convention every school calculator adopts. If every field is zero, no answer is shown.

Is the least common denominator the same as the LCM?

Yes — the least common denominator of a set of fractions is the least common multiple of their denominators. To add 1/8 and 1/12, take lcm(8, 12) = 24, rewrite as 3/24 and 2/24, and add to get 5/24. Using a larger common denominator such as 96 also works and gives 12/96 + 8/96 = 20/96, which reduces back to 5/24 — the same answer with more arithmetic.

What is the LCM of two prime numbers?

Their product, provided they are different primes. Distinct primes share nothing, so nothing is double-counted and lcm(7, 13) = 91. If both entries are the same prime the LCM is that prime, since lcm(7, 7) = 7. More generally, lcm(n, n) = n for any number.

Can I use the LCM with negative numbers?

Enter them if you like — the calculator uses absolute values. The least common multiple is defined as a positive quantity, because the set of common multiples of any pair contains both positive and negative values and only the positive ones have a smallest member. So lcm(−4, 6) is reported as 12, the same as lcm(4, 6).

How big can the least common multiple get?

Quickly very large: the LCM of 1 through 10 is 2,520, and of 1 through 20 it is 232,792,560. This calculator accepts entries up to 10¹² and reports the LCM whenever it stays within 2⁵³, the largest integer a browser stores exactly; past that the value is suppressed rather than shown wrong. Reduce an entry, or use arbitrary-precision software, if you need to go further.

Why is dividing before multiplying recommended?

Because a ÷ gcd(a, b) is always a whole number, so no accuracy is lost, and the intermediate value stays as small as possible. Computing a × b first can push the intermediate result past the exact-integer limit even when the final LCM is comfortably inside it. For 999,999,937 and 999,999,893 the product exceeds 10¹⁸, while the divide-first route never leaves exact range until the final multiplication.

References

  • An Introduction to the Theory of Numbers, 6th ed. — Oxford University Press (Hardy & Wright)
  • Concrete Mathematics, 2nd ed., Chapter 4: Number Theory — Addison-Wesley (Graham, Knuth & Patashnik)
  • Elementary Number Theory and Its Applications, 6th ed. — Pearson (Rosen)
  • The Art of Computer Programming, Vol. 2: Seminumerical Algorithms, 3rd ed., §4.5.2 — Addison-Wesley (Knuth)