Worked examples

LCM worked examples, checked step by step

Every result on this page was computed with exact integer arithmetic, and the intermediate values were re-checked before publication. Each example shows the method and the reasoning, not only the final answer.

Quick LCM answers with links to the working

Use these examples to check your arithmetic, then open the calculation to compare methods. The fraction rows deliberately use the same inputs to show why rational LCM and LCD are not interchangeable.

Inputs, exact answers and reproducible working
Inputs and operationAnswerOpen example
LCM(12, 18)36Prime factors
LCM(4, 6, 8)24Three-number calculation
LCM(1 through 10)2520Range calculation
Rational LCM(1/2, 3/4)3/2Rational multiple
LCD(1/2, 3/4)4Equivalent fractions

See which method to choose or read the rational LCM and LCD definitions.

How to read these examples

The tool names below match the methods described on the How it works page. Where a method has a natural limit — factorisation above 1,000,000, or the 10,000-step search budget for listing — the limit is stated in the example instead of being hidden.

Results are shown in full. Nothing here is rounded, estimated or abbreviated, and no example relies on a floating-point calculation for an integer result.

LCM word problems with answers

When will two repeating events happen together?

Two classroom timers ring together at the start. One rings every 12 minutes and the other every 18 minutes. When will they next ring together?

  1. Write the intervals as prime factors: 12 = 2² × 3 and 18 = 2 × 3².
  2. Keep the greatest power of each prime: 2² × 3² = 36.
  3. The timers next ring together after 36 minutes: that is three 12-minute intervals and two 18-minute intervals.

This works because both timers start together and repeat at fixed intervals. Different starting times require checking the offsets too; the LCM alone is not enough.

What is the smallest equal quantity from different pack sizes?

Pencils come in packs of 8 and erasers in packs of 12. To buy the same positive number of each with no partial packs, find LCM(8, 12) = 24. Buy three packs of pencils and two packs of erasers.

Use LCM when looking for a smallest shared multiple. If instead you are splitting fixed quantities into the greatest number of identical groups with nothing left over, that is a GCF/GCD problem.

Review the prime factorization method, then try these inputs in the LCM calculator with steps.

Try the timer example: 12 and 18 Try the pack example: 8 and 12

Two small integers with the GCD method

The identity lcm(a, b) = |a × b| ÷ gcd(a, b) handles all of these in one step each.

Two-integer examples
InputGCDWorkingLCM
12 and 18612 × 18 = 216; 216 ÷ 636
21 and 6321 × 6 = 126; 126 ÷ 342
9 and 1239 × 12 = 108; 108 ÷ 336
15 and 25515 × 25 = 375; 375 ÷ 575
7 and 111Coprime, so the LCM is the product77

Euclid's steps for 12 and 18

  1. 18 mod 12 = 6
  2. 12 mod 6 = 0 → the last non-zero remainder is 6, so gcd(12, 18) = 6
  3. 216 ÷ 6 = 36, and 36 ÷ 12 = 3 with no remainder, 36 ÷ 18 = 2 with no remainder

Three or more integers: fold from the left

With more than two inputs, the same identity is applied repeatedly: lcm(a, b, c) = lcm(lcm(a, b), c). Because the LCM is associative in this way, the order of folding does not change the result.

Multi-integer examples
InputWorkingLCM
4, 6, 8lcm(4, 6) = 12; then lcm(12, 8) = 2424
10, 15, 20lcm(10, 15) = 30; then lcm(30, 20) = 6060
14, 21, 35lcm(14, 21) = 42; then lcm(42, 35) = 210210
20, 30, 40lcm(20, 30) = 60; then lcm(60, 40) = 120120
6, 8, 12lcm(6, 8) = 24; then lcm(24, 12) = 2424

Note the last row: once the running LCM already contains a number, that number changes nothing. This is also why, for inputs such as 4 and 12 where one divides the other, the LCM is simply 12.

Prime-power examples (inputs within the 1,000,000 factorisation limit)

Prime-power working
InputFactorisationHighest powersLCM
12, 182²·3 and 2·3²2², 3²36
4, 6, 82² and 2·3 and 2³2³, 3¹24
45, 603²·5 and 2²·3·52², 3², 5¹180
50, 75, 1002·5² and 3·5² and 2²·5²2², 3¹, 5²300
16, 402⁴ and 2³·52⁴, 5¹80

Check one row by hand: 45 = 3² × 5, 60 = 2² × 3 × 5, and the product 45 × 60 ÷ gcd(45, 60) = 2700 ÷ 15 = 180. The prime-power route and the GCD route agree, as they must.

Listing multiples, with the search budget shown

Listing is the easiest method to explain, and also the first to run out of room. For 8 and 12 the multiples begin 8, 16, 24 and 12, 24, so the first shared value is 24.

The interface shows the first 12 multiples of each number. Behind the scenes the tool allows at most 10,000 candidate steps. If the exact result proves listing would exceed that budget, it skips that search, switches to Euclid, and labels the switch in the working. Coprime pairs such as 7 and 11 are exactly the case where the answer is the product (77), and where a short listing would be misleading if it were presented as the whole search.

Ladder and common division, step by step

Ladder for 12 and 18

Ladder rows
StepRowAction
Start12, 18
16, 9both entries are even, so both are divided by 2
23, 96 is divided by 2 again; the 9 is odd and carried down
31, 33 divides both entries
41, 13 divides the remaining 3; every entry has reached 1

LCM = 2 × 2 × 3 × 3 = 36

Common division for 6, 8 and 12

Common division rows
StepRowAction
Start6, 8, 12
13, 4, 62 divides all three entries, so all three are divided
23, 2, 32 divides 4 and 6; the 3 is carried down
31, 2, 13 divides both 3s; the 2 is carried down

No prime divides two entries of the row 1, 2, 1, so common division stops there instead of dividing the remaining 2 on its own. That leftover 2 is multiplied in with the side divisors:

LCM = 2 × 2 × 3 × 2 = 24

Binary GCD as an independent cross-check

gcd(48, 18) by binary GCD: both values are even, so halve both and keep one factor of 2, leaving 24 and 9. Reduce the even value by halving it: 24 → 12 → 6 → 3. The pair is now 3 and 9; both are odd, so subtract the smaller from the larger: 9 − 3 = 6, then remove the factor of 2 from that even result by halving 6 → 3. The pair is now 3 and 3, and subtracting gives 3 − 3 = 0, so the common value is 3. Restoring the shared factor of 2 gives gcd(48, 18) = 3 × 2 = 6. Euclid agrees: 48 mod 18 = 12, 18 mod 12 = 6 and 12 mod 6 = 0, so the last non-zero remainder is 6.

lcm(48, 18) = 48 × 18 ÷ 6 = 144

Range mode: 1 to n

Range mode computes the LCM of every integer from 1 up to n, for n up to 100. These are the classic results students meet first.

Range examples
RangeLCMNote
1 to 560built up as 1, 2, 6, 12, 60
1 to 102520divisible by every number from 1 to 10
1 to 1227720adds the prime 11 on top of the 1-to-10 result: 2520 × 11 = 27720, and 11 first appears in this range

Check 1 to 10 by dividing every value, not just a sample: 2520 ÷ 1 = 2520, ÷ 2 = 1260, ÷ 3 = 840, ÷ 4 = 630, ÷ 5 = 504, ÷ 6 = 420, ÷ 7 = 360, ÷ 8 = 315, ÷ 9 = 280 and ÷ 10 = 252. Each division is exact, so all ten values divide 2520. It is also the smallest such number: every common multiple must contain 2³, 3², 5 and 7 to be divisible by 8, 9, 5 and 7. These prime powers are pairwise coprime, so every common multiple is divisible by their product, 2520.

Batch LCM: check independent sets of numbers

Use Batch when each line is a separate problem, not when you want one LCM for the entire list. Enter up to 50 non-empty lines, each containing 2–20 signed integers of up to 100 digits each. The input box has a 50,000-character total limit, so these maximums cannot all be used at once. Blank lines are ignored; an invalid line is reported without discarding the valid results.

Two independent LCM calculations
LineInputLCMGCF / GCD
112, 18366
28, 12, 201204

Try both Batch calculations

The summary shows 2 / 2 successful lines, not a combined LCM. Batch uses exact integer arithmetic and reports an LCM and GCF per line; it does not run the six teaching methods separately for every row. Download saves the results as CSV for a worksheet check. A line containing only 7 is invalid because a calculation needs at least two numbers.

For one result across several inputs, use LCM of three or more numbers. For consecutive integers, use Range mode.

Large integers

Integer inputs are handled with BigInt, so large values are exact. These two examples show both cases: one where a shared factor shrinks the answer, and one where the inputs are coprime.

Large-integer examples
InputGCDResult
123456789 and 987654321913548070123626141
10⁹⁹ + 1 and 10⁹⁹ + 31the exact product, a 199-digit value

For the second row, the GCD is 1, so the LCM is the product of the two inputs, which can be written exactly without expanding it as digits:

lcm = (10⁹⁹ + 1) × (10⁹⁹ + 3) = 10¹⁹⁸ + 4 × 10⁹⁹ + 3

That expression is a 199-digit integer — the leading 1, then 98 zeros, then a 4, then 98 more zeros, and a final 3. Writing it as a power expression avoids the line-wrapping errors that long digit strings invite.

Fractions and finite decimals

Fractions are reduced first, then combined as LCM of the reduced numerators over GCD of the reduced denominators. Finite decimals are converted to exact fractions before reduction; up to 12 decimal places are accepted.

Rational examples
InputReduced, then combinedResult
1/2 and 3/4lcm(1, 3) = 3 over gcd(2, 4) = 23/2 = 1.5
2/3 and 4/9lcm(2, 4) = 4 over gcd(3, 9) = 34/3
3/8 and 5/6lcm(3, 5) = 15 over gcd(8, 6) = 215/2 = 7.5
0.5 and 1.251/2 and 5/4 → lcm(1, 5) = 5 over gcd(2, 4) = 25/2 = 2.5

This rational result is a numerator/denominator convention and is not the same thing as the lowest common denominator. The convention is documented on the About & sources page, including the community discussion it is drawn from.

The separate LCD option

When the goal is to add or compare fractions, use the LCD option instead. It reduces the denominators, finds their LCM, and rewrites every fraction as an equivalent fraction with that denominator.

Lowest common denominator examples
InputReduced denominatorsLCDEquivalent fractions
1/6 and 1/86 and 8244/24 and 3/24
2/15 and 3/1015 and 10304/30 and 9/30

Each rewritten fraction equals its original: 4/24 = 1/6 and 3/24 = 1/8, so adding them as 7/24 is valid. The LCD is a denominator, so it is reported as a positive whole number even when the original fractions were negative.

Edge cases and the conventions behind them

Convention examples
InputResultReason
LCM(−12, 18)36negatives are treated by magnitude
LCM(0, 5)0any zero input gives 0 by convention
LCM(0, 0)0the same zero convention
gcd(0, 0)0all-zero GCD convention
LCM(7, 7)7identical inputs share themselves
LCM(4, 12)12one input divides the other
LCM(2, 3, 5, 7)210four distinct primes, so the product

Every convention in this table is applied consistently across the calculator, the batch input, the range mode and the rational mode, so a result computed one way matches the same result computed another way.

Reproduce these results yourself

Enter any pair above in the LCM calculator, or read the method notes on the How it works page. The definitions and algorithms used here are established mathematics; the reference list behind them is on the About & sources page.