Skip to content

LCM

Returns the least common multiple: the smallest positive whole number that all the numbers you give it divide into exactly.

Syntax

=LCM(, [number2], …)

Math and trigonometry

All versions of Excel.

Try it

Edit the formula in C2 or change the inputs. The sheet recalculates as you type.

C2
A
B
C
1
First
Second
LCM
2
4
6
12
3

C2 =LCM(A2,B2) returns 12

How LCM works

LCM finds the smallest number that every one of your inputs divides into with nothing left over. =LCM(4, 6) is 12, because 12 is the first number on both the 4 times table and the 6 times table.

Repeating cycles

The most practical use is finding when repeating schedules line up again. If one machine is serviced every 10 days, another every 15 and a third every 12, they all fall due on the same day every =LCM(10, 15, 12) = 60 days. The same method works for staff rotas, delivery rounds, payment cycles and any pattern that repeats.

To count how often the cycles coincide in a period, divide: =360/LCM(B2:B4) gives the number of times in a 360-day year when all three land together, as long as the result comes out whole.

Common denominators

To add fractions with different denominators, the lowest common denominator is the LCM of the denominators. =LCM(4, 6) is 12, so 1/4 + 1/6 is worked out in twelfths as 3/12 + 2/12.

Ranges and several numbers

LCM accepts up to 255 numbers or ranges: =LCM(B2:B4) and =LCM(10, 15, 12) both work. Putting a range in is the easiest way to include many values.

Unusual input

  • Decimals are truncated: =LCM(4.9, 6) works on 4.
  • If any number is 0, the result is 0.
  • Negative numbers return #NUM!. Take ABS first.
  • Text returns #VALUE!.

Large results

The LCM of several large or co-prime numbers can be very big. Co-prime numbers have no common factor, so their LCM is their product. LCM(7, 11, 13) is 1,001. Check that a huge result is not a sign that the schedules never realistically align, and that you meant all of them to be included.

LCM and GCD

GCD is the companion function. For two numbers, =A2*B2/GCD(A2,B2) equals =LCM(A2,B2). Use GCD for splitting things into equal groups and LCM for finding when things repeat together.

PRODUCT multiplies the numbers, which gives a common multiple but usually not the least one. For 10, 15 and 12 the product is 1,800, 30 times too big.

Arguments

number1
The first number or range, such as B2:B4. Negative numbers return #NUM!.
number2, …optional
More numbers or ranges, up to 255 arguments. Decimals are cut off to whole numbers.

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

Example 1

LCM of two numbers

C2 =LCM(A2,B2)

Result: 12

12 is the smallest number that both 4 and 6 divide into exactly.

C2
A
B
C
1
First
Second
LCM
2
4
6
12
3

C2 =LCM(A2,B2) returns 12

Example 2

When do three service cycles coincide?

D2 =LCM(B2:B4)

Result: 60

After 60 days all three machines are due on the same day.

D2
A
B
C
D
1
Machine
Service every (days)
All together every
2
Press
10
60
3
Lathe
15
4
Mill
12
5

D2 =LCM(B2:B4) returns 60

Example 3

Co-prime numbers: LCM is the product

C2 =LCM(A2,B2)

Result: 35

7 and 5 share no factor, so the first time they meet is 7 x 5.

C2
A
B
C
1
First
Second
LCM
2
7
5
35
3

C2 =LCM(A2,B2) returns 35

Example 4

A zero makes the LCM zero

C2 =LCM(A2,B2)

Result: 0

If one of the numbers is 0 the result is 0. Check for blank cells in a range.

C2
A
B
C
1
First
Second
LCM
2
0
5
0
3

C2 =LCM(A2,B2) returns 0

Example 5

Negative numbers give #NUM!

C2 =LCM(A2,B2)

Result: #NUM!

Wrap each argument in ABS if negatives can occur: LCM(ABS(A2), ABS(B2)).

C2
A
B
C
1
First
Second
LCM
2
-3
4
#NUM!
3

C2 =LCM(A2,B2) returns #NUM!

Your turn.

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 2

In D2, return the number of days after which all three machines are due for service on the same day.

Answer in D2.

D2
A
B
C
D
E
1
Machine
Service every (days)
All together every
2
Press
10
3
Lathe
15
Times in 360 days
4
Mill
12
5
6
7
8

Common mistakes

  • Negative numbers return #NUM!. Take ABS of each argument if signs can vary.
  • A zero anywhere in the list makes the result 0. Blank cells inside a range don't count as zero, but an actual 0 does.
  • The LCM of many numbers can be huge, and a very large result may return #NUM!. Check the inputs are the cycles you mean.
  • Decimals are truncated, not rounded, so LCM(4.9, 6) works on 4. Use whole numbers.
  • Multiplying the numbers gives a common multiple but rarely the least one. 10*15*12 is 1,800, not 60.

Questions people ask

What does LCM do in Excel?

It returns the least common multiple: the smallest positive number that all your inputs divide into exactly. LCM(4, 6) is 12.

How do I find when repeating events line up?

Use LCM on the cycle lengths. Services every 10, 15 and 12 days all fall on the same day every `=LCM(10,15,12)`, or 60 days.

How do I find a common denominator for fractions?

Take the LCM of the denominators. For 1/4 and 1/6, `=LCM(4,6)` is 12, so both can be written in twelfths.

Can LCM take a range?

Yes. `=LCM(B2:B9)` uses every number in the range, up to 255 arguments in total.

What is the link between LCM and GCD?

For two numbers, LCM = A x B / GCD. For 12 and 18, the GCD is 6 and the LCM is 12 x 18 / 6 = 36.

Learn LCM in a real sheet.

Tracks take you from the basics to modelling, one graded exercise at a time.