LCM Calculator
Enter two or more whole numbers to find their least common multiple.
Updated
LCM Calculator
Our LCM Calculator finds the least common multiple of any list of whole numbers: two numbers, three numbers or a long list. Type or paste the numbers and the LCM appears straight away, with the prime factors of each number and the greatest common divisor (GCD) shown underneath. It is exact for very large numbers too, which makes it handy for fraction homework, repeating schedules, gear ratios and programming puzzles.
Quick answer
The least common multiple (LCM) is the smallest positive number that every number in the list divides into exactly. For example, the LCM of 4 and 6 is 12, and the LCM of 4, 6 and 10 is 60. Enter any whole numbers above and the calculator shows the LCM instantly.
- Two numbers: LCM(a, b) = a × b ÷ GCD(a, b)
- Prime factors: multiply the highest power of every prime that appears
- More numbers: LCM(a, b, c) = LCM(LCM(a, b), c)
- Shortcuts: two primes give their product; if one number divides the other, the LCM is the larger one
What Is the LCM?
A multiple of a number is that number times 1, 2, 3 and so on. A common multiple of several numbers is a number that appears in all of their lists, and the least common multiple is the smallest one. Every common multiple is a multiple of the LCM, so once you know the LCM you know them all.
Multiples of 6: 6, 12, 18, 24, 30, 36
Common multiples: 12, 24, 36, …
LCM(4, 6) = 12
The LCM is also called the lowest common multiple or the smallest common multiple. It is always at least as large as the biggest number in the list and never larger than the product of all the numbers.
How to Find the LCM
1. List the multiples. Write out multiples of the largest number until you reach one that all the other numbers divide into. This is quick for small numbers: multiples of 10 are 10, 20, 30, …, 60, and 60 is the first one that 4 and 6 also divide, so LCM(4, 6, 10) = 60.
2. Use prime factors. Break each number into primes, then take every prime that appears, at its highest power:
16 = 2⁴
20 = 2² × 5
Highest powers: 2⁴, 3, 5
LCM = 2⁴ × 3 × 5 = 16 × 3 × 5 = 240
3. Use the GCD. For two numbers, divide their product by their greatest common divisor. For more numbers, repeat it one pair at a time. This is the method the calculator uses, because it stays fast even for 30-digit numbers.
LCM(8, 12) = 96 ÷ 4 = 24
LCM(8, 12, 20) = LCM(24, 20) = 480 ÷ 4 = 120
Worked Examples
Six numbers. Find the LCM of 4, 6, 7, 2, 15 and 77. First write each number as a product of primes:
| Number | Prime factors |
|---|---|
| 2 | 2 |
| 4 | 22 |
| 6 | 2 × 3 |
| 7 | 7 |
| 15 | 3 × 5 |
| 77 | 7 × 11 |
LCM = 4 × 3 × 5 × 7 × 11 = 4,620
Repeating events. Event A happens every 4 days, event B every 6 days and event C every 10 days. If all three happen today, they next fall on the same day after LCM(4, 6, 10) = 60 days.
Packs that match. Hot dogs come in packs of 10 and buns in packs of 8. To end up with the same number of each, buy LCM(10, 8) = 40 of each: 4 packs of hot dogs and 5 packs of buns.
| Numbers | GCD | LCM |
|---|---|---|
| 4, 6 | 2 | 12 |
| 8, 12 | 4 | 24 |
| 9, 15 | 3 | 45 |
| 7, 11 | 1 | 77 |
| 5, 10, 15 | 5 | 30 |
| 12, 16, 20 | 4 | 240 |
| 1 to 10 | 1 | 2,520 |
LCM and GCD
The greatest common divisor (GCD), also called the greatest common factor (GCF) or highest common factor (HCF), is the largest number that divides into all the numbers. The LCM uses the highest power of each prime, and the GCD uses the lowest power that appears in every number. For two numbers they are linked by a simple rule:
8 = 2³, 12 = 2² × 3
LCM = 2³ × 3 = 24, GCD = 2² = 4
24 × 4 = 96 = 8 × 12
The rule only works for two numbers. For 2, 4 and 8 the LCM is 8 and the GCD is 2, so LCM × GCD = 16, while the product is 64.
The LCM and Fractions
Fractions can only be added or subtracted when they share a denominator. The LCM of the denominators is the least common denominator (LCD), the smallest one that works:
LCM(4, 6) = 12
= 3/12 + 2/12 = 5/12
Multiplying the denominators (4 × 6 = 24) also works, but it gives 6/24 + 4/24 = 10/24, which then has to be simplified back to 5/12.
LCM in Excel and Code
| Tool | LCM of 4, 6 and 10 |
|---|---|
| Excel / Google Sheets | =LCM(4, 6, 10) |
| Excel, a range | =LCM(A1:A10) |
| Python 3.9+ | math.lcm(4, 6, 10) |
| JavaScript | a / gcd(a, b) * b |
Excel’s LCM returns #NUM! for negative numbers and drops the decimal part of non-whole numbers. JavaScript has no built-in LCM, so you write a small GCD function first. Dividing before multiplying keeps the numbers small and avoids overflow.
Common Mistakes
- Multiplying the numbers. 4 × 6 = 24 is a common multiple, but the least one is 12.
- Mixing up LCM and GCD. The LCM of 8 and 12 is 24; the GCD is 4.
- Taking the lowest powers. The lowest powers give the GCD. The LCM needs the highest, such as 2⁴ (not 2²) for 12, 16 and 20.
- Missing a prime. A prime that appears in only one number, such as the 11 in 77, must still be included.
- Using LCM × GCD = product for three numbers. The rule only holds for two numbers.
Key Terms
- Multiple
- A number times a whole number: 18 is a multiple of 6.
- Common multiple
- A number that is a multiple of every number in the list.
- LCM
- Least common multiple: the smallest positive common multiple.
- GCD
- Greatest common divisor (also GCF or HCF): the largest number that divides into every number in the list.
- Prime factors
- A number written as a product of primes, such as 60 = 2² × 3 × 5.
- Coprime
- Numbers with a GCD of 1, such as 8 and 9. Their LCM is their product.
- LCD
- Least common denominator: the LCM of the denominators of a set of fractions.
How to Use the LCM Calculator
- Enter your numbers. Type two or more whole numbers in the “Numbers” box, separated by spaces or commas, for example 4 6 10. You can enter up to 200 numbers, and you can paste a column straight from a spreadsheet.
- Read the LCM. The least common multiple appears as you type, with the working underneath (for example LCM(4, 6, 10) = 60). The table below it shows the prime factors of each number, with the highest power of each prime in bold, and the greatest common divisor (GCD).
- Copy the result. Press Copy to copy the LCM. Press Clear or Esc to start again.
Example: enter 12 16 20 and the LCM is 240, with the working LCM(12, 16, 20) = 240, the factors 2⁴ × 3 × 5 and a GCD of 4.
Who Can Use This Calculator?
Frequently Asked Questions (FAQs)
What is the least common multiple (LCM)?
The LCM of two or more whole numbers is the smallest positive number that every one of them divides into exactly. The LCM of 4 and 6 is 12: the multiples of 4 are 4, 8, 12, 16 and so on, the multiples of 6 are 6, 12, 18 and so on, and 12 is the first number in both lists.
How do you find the LCM of two numbers?
Divide the product of the two numbers by their greatest common divisor: LCM(a, b) = a × b ÷ GCD(a, b). For 8 and 12 the GCD is 4, so the LCM is 8 × 12 ÷ 4 = 96 ÷ 4 = 24. You can also list multiples of the larger number (12, 24, …) until you reach one the smaller number divides into.
How do you find the LCM of three or more numbers?
Write each number as a product of primes and multiply the highest power of every prime that appears. For 12, 16 and 20: 12 = 22 × 3, 16 = 24 and 20 = 22 × 5, so the LCM is 24 × 3 × 5 = 240. Another way is to work in pairs: LCM(a, b, c) = LCM(LCM(a, b), c).
What is the difference between LCM and GCD (HCF)?
The LCM is the smallest number that all the numbers divide into, so it is at least as big as the largest number. The GCD, also called the greatest common factor (GCF) or highest common factor (HCF), is the largest number that divides into all of them, so it is at most the smallest number. For 8 and 12 the LCM is 24 and the GCD is 4. For two numbers, LCM × GCD = the product of the numbers (24 × 4 = 96 = 8 × 12).
What is the LCM of two prime numbers?
Their product, because two different primes share no factors. The LCM of 7 and 11 is 77. The same is true for any two coprime numbers (numbers whose GCD is 1): the LCM of 8 and 9 is 72.
What is the LCM when one number is a multiple of the other?
It is the larger number. 10 is a multiple of 5, so LCM(5, 10) = 10. Likewise LCM(2, 4, 8) = 8.
How is the LCM used with fractions?
To add or subtract fractions, rewrite them over a common denominator. The LCM of the denominators is the least common denominator (LCD), which keeps the numbers as small as possible: 1/4 + 1/6 = 3/12 + 2/12 = 5/12, because LCM(4, 6) = 12.
What is the LCM of 0, negative numbers or decimals?
0 is a multiple of every number, so this calculator, Excel and Python all give an LCM of 0 for any list that contains 0. Minus signs are ignored, because the LCM is always positive: LCM(−4, 6) = 12. The LCM is defined for whole numbers only. For decimals such as 0.4 and 0.6, multiply by 10 to get 4 and 6, find the LCM (12) and divide by 10 again: 1.2.
Can the LCM be smaller than the numbers?
No. Every number in the list must divide into the LCM, so the LCM is always at least as large as the largest number. It is never larger than the product of all the numbers.
Is the LCM Calculator free?
Yes. It is completely free, needs no sign-up, and can be used as many times as you like.
Try our LCM Calculator to find the least common multiple of any whole numbers instantly.