The LCM function returns the smallest positive integer that is a multiple of every number you supply. It is useful whenever you need to align repeating cycles, such as schedules, packaging sizes, or gear rotations.
=LCM(number1, [number2], …)What does LCM do?
The LCM function calculates the least common multiple of one or more numbers. In plain terms, it finds the smallest number that all your input numbers divide into evenly. For example, the least common multiple of 4 and 6 is 12, because 12 is the first number that both 4 and 6 can divide without a remainder.
This matters in everyday office and study work. Whenever two or more repeating events need to line up, LCM tells you when they will next coincide. That could be two delivery trucks arriving on different cycles, two machines producing at different rates, or two students finishing revision tasks of different lengths.
A practical situation: you manage a small print shop. One printer finishes a batch every 8 minutes and another every 12 minutes. Using LCM, you can quickly work out that both printers will finish a batch together every 24 minutes, which helps you plan the next job without guesswork.
When to use LCM
- Finding when two repeating schedules next coincide
- Matching packaging sizes to a full carton quantity
- Working out gear or pulley rotation alignment
- Solving fraction addition problems in maths homework
- Planning maintenance cycles for machines with different service intervals
- Coordinating delivery slots from suppliers on different routes
LCM syntax
=LCM(number1, [number2], …)| Argument | Required? | What to enter |
|---|---|---|
number1 | Required | The first number or cell reference. Must be zero or a positive integer. Example: 12 or B2. |
number2 | Optional | An optional additional number or cell reference. You can add up to 255 numbers in total. Example: 18 or C2. |
What it returns: A positive integer: the smallest number that is a multiple of every supplied number. If any argument is zero, LCM returns 0.
LCM examples
1 Two numbers: basic least common multiple
This example finds the least common multiple of two batch sizes. The formula =LCM(B2,C2) takes the value in B2 (6) and the value in C2 (8) and returns the smallest number both divide into evenly. Six and eight share 24 as their first common multiple, so the result is 24. Use this when you simply need to compare two repeating quantities.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Item | Batch A | Batch B | |||
| 2 | Units per pack | 6 | 8 | 24 | ||
| 3 | Notes | Small packs | Large packs | |||
| 4 |
2 Three numbers: aligning three repeating cycles
Here three machines finish jobs on cycles of 4, 6, and 10 minutes. The formula =LCM(B2,C2,D2) finds the first minute when all three cycles end together. Four, six, and ten all divide into 60, so the result is 60. This helps you schedule a shared inspection or reset point.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Machine | Cycle A (mins) | Cycle B (mins) | Cycle C (mins) | |||
| 2 | Press 1 | 4 | 6 | 10 | 60 | ||
| 3 | Press 2 | 5 | 9 | 12 | |||
| 4 |
3 Using a range of cells
The LCM function accepts a range, so you can calculate the common multiple for a whole column of values at once. The formula =LCM(B2:B5) looks at 3, 5, 7, and 2 and returns 210, the smallest number all four divide into. This is handy when you have a list of cycle lengths and do not want to type each cell reference.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Task | Days | |||
| 2 | Task A | 3 | 210 | ||
| 3 | Task B | 5 | |||
| 4 | Task C | 7 | |||
| 5 | Task D | 2 | |||
| 6 |
Common LCM errors and how to fix them
| Error | Why it happens | How to fix it |
|---|---|---|
| #VALUE! | One of the arguments is text that cannot be converted to a number, such as an empty text string or a word. | Check that every referenced cell contains a number or is blank. Replace text values with numeric values or remove them from the range. |
| #NUM! | An argument is negative. LCM only accepts zero or positive integers. | Use the ABS function to convert negative values to positive, or correct the source data so all numbers are zero or greater. |
| #NAME? | The function name is misspelled, for example =LCM( written as =LMC(. | Type =LCM( and let Excel suggest the function, or correct the spelling manually. |
| 0 returned unexpectedly | One of the numbers is zero. LCM returns 0 whenever any argument is zero. | Remove or replace zero values in the referenced cells if you expect a positive multiple. |
Tips for using LCM
- LCM ignores blank cells and logical values in a range, so you can point it at a column that is not yet fully filled.
- If you need the least common multiple of many numbers, use a range such as
B2:B20instead of typing each cell reference. - Remember that LCM returns 0 if any argument is 0; use
IFor data validation to prevent accidental zeros. - For large numbers, the result can grow quickly. LCM of 12, 18, and 24 is 72, but adding 35 raises it to 2520.
- Combine LCM with
EDATEor simple addition to turn a day count into an actual calendar date for scheduling.
Frequently asked questions
What is the difference between LCM and GCD?
LCM finds the smallest number that all inputs divide into, while GCD (greatest common divisor) finds the largest number that divides into all inputs. For 12 and 18, LCM is 36 and GCD is 6.
Can LCM handle decimal numbers?
LCM truncates decimal values to integers before calculating. For example, 2.9 is treated as 2. If you need exact decimal multiples, scale the numbers to whole units first.
Why does LCM return 0?
If any argument is zero, the least common multiple is defined as 0 in Excel. Check your referenced cells for zeros or empty cells that evaluate to zero.
Does LCM work with dates?
Dates are stored as serial numbers in Excel, so LCM will treat a date as a large integer. It is rarely useful directly on dates; instead, use LCM on the interval in days and add the result to a start date.
Related functions
Every example on this page was recalculated by SheetSkill’s spreadsheet engine. LCM reference