LCM Calculator (Least Common Multiple)

Math

Choose how many numbers you have, from 2 to 5, and enter them. The calculator finds their least common multiple (LCM) and greatest common factor (GCF), and shows the prime factorization of each number.

How many numbers?

A whole number from 1 to 1,000,000.

Your entries stay on your device. The math runs right in your browser.

Result: Least common multiple (LCM)

36

The LCM of 12 and 18 is 36. Their GCF is 6.

  • Greatest common factor (GCF): 6

Prime factorization of your numbers

Prime factorization of your numbers
NumberPrime factors
122² · 3
182 · 3²

Step by step

LCM(12, 18) = 12 · 18 / 6 = 36

  1. Prime factors: 12 = 2² · 3 and 18 = 2 · 3².
  2. Take each prime to its highest power: LCM = 2² · 3² = 36.
  3. The GCF is 6. Check: 12 · 18 / 6 = 216 / 6 = 36.

Formula

LCM(a, b) = a · b / GCF(a, b)
LCM = p1m1 · p2m2 · … · pkmk
a, b, c
the numbers whose LCM you want
GCF
the greatest common factor of the two numbers
p1, …, pk
the primes that divide at least one of the numbers
m1, …, mk
the highest power with which each of those primes appears in any one of the numbers

How it works

Take any group of whole numbers. Their least common multiple (LCM) is the smallest positive number that every one of them divides evenly, and it is also called the lowest common multiple. The multiples of 4 are 4, 8, 12, 16, 20 and 24, and the multiples of 6 are 6, 12, 18 and 24. They share 12 and 24, and the smallest shared multiple is 12, so the LCM of 4 and 6 is 12. When the numbers are the denominators of fractions, the LCM is the least common denominator.

The calculator uses prime factorization. It writes each number as a product of primes, takes every prime that shows up, raises it to the highest power it has in any of the numbers, and multiplies the results. For 12 = 2² · 3 and 18 = 2 · 3², that gives 2² · 3² = 36. The greatest common factor (GCF) comes from the same factorizations, but it keeps only the primes that appear in every number, each to its lowest power: 2 · 3 = 6. For two numbers, LCM × GCF equals the product of the numbers, so 36 × 6 = 12 × 18 = 216.

By hand, you can list the multiples of the largest number until you reach one that all the other numbers divide. If one number divides the other, the LCM is the larger one. If two numbers share no factor besides 1, which makes them relatively prime, the LCM is their product, so the LCM of 3 and 5 is 15. The LCM is how you find a common denominator, which is the step behind adding and subtracting fractions in the fraction calculator, and it tells you when repeating schedules line up again. For the opposite question, use the GCF calculator, and to list every factor of a number, use the factor calculator. Enter whole numbers from 1 to 1,000,000. If the LCM would be larger than 9,007,199,254,740,991, it can't be shown exactly and the calculator tells you so.

The formula

A multiple of a number contains all of that number's prime factors. A common multiple therefore has to contain each prime at least as many times as it appears in the number that has the most copies of it. The least common multiple uses exactly that many copies and no more.

That is why LCM(a, b) = a · b / GCF(a, b). In the product a · b, the primes the two numbers share are counted twice, and dividing by the GCF removes one copy of each. With more than two numbers the product rule no longer works, so the calculator takes the highest power of each prime directly. That gives the same answer as combining two numbers at a time: LCM(a, b, c) = LCM(LCM(a, b), c).

Example

Hot dogs come in packs of 10 and buns in packs of 8. What is the fewest of each you can buy with nothing left over?

  1. The smallest equal count is the LCM. Prime factors: 10 = 2 · 5 and 8 = 2³.
  2. Take each prime to its highest power: 2³ from the 8 and 5 from the 10, so LCM = 2³ · 5 = 40.
  3. Buy 40 of each: 40 / 10 = 4 packs of hot dogs and 40 / 8 = 5 packs of buns. The GCF is 2, and 80 / 2 = 40 confirms the LCM.

The LCM of 10 and 8 is 40. Their GCF is 2.

Load this example into the calculator

Frequently asked questions

How do I calculate the LCM?

Factor each number into primes, take every prime to the highest power it has in any of the numbers, and multiply. For 20 = 2² · 5 and 30 = 2 · 3 · 5, that is 2² · 3 · 5 = 60. For two numbers you can also divide their product by the GCF: 20 · 30 / 10 = 60. Or list multiples until the first match.

What is the LCM of 24 and 36?

It is 72. In primes, 24 = 2³ · 3 and 36 = 2² · 3², so the LCM is 2³ · 3² = 72. The GCF is 2² · 3 = 12, and the check works: 24 · 36 / 12 = 864 / 12 = 72. The multiples of 24 are 24, 48, 72, and 72 is also a multiple of 36.

What is the least common multiple of 8 and 12?

It is 24. The multiples of 8 are 8, 16, 24 and the multiples of 12 are 12, 24, so 24 is the first one they share. With primes, 8 = 2³ and 12 = 2² · 3 give 2³ · 3 = 24. The GCF of 8 and 12 is 4, and 8 · 12 / 4 = 24.

What is the LCM of 4 and 2?

It is 4. Since 2 divides 4 evenly, 4 is already a multiple of both numbers, and nothing smaller is a multiple of 4. This holds whenever one number divides the other: the LCM is the larger number.

What is the LCM (lowest common multiple)?

The LCM, also called the lowest or least common multiple, is the smallest positive whole number that is a multiple of every number in a set. For 4 and 6 it is 12. It always exists for positive whole numbers and is never smaller than the largest number in the set.

What does an LCM calculator do?

It finds the smallest number that all of your numbers divide evenly. This one also shows the greatest common factor, the prime factorization of every number, and the steps that lead to the answer, so you can follow along or check homework.

How is LCM different from GCD?

The LCM is the smallest number that all the numbers divide, so it is at least as large as the largest of them. The GCD, also called the GCF, is the largest number that divides all of them, so it is at most the smallest. For 12 and 18 the LCM is 36 and the GCD is 6.

What is the relationship between LCM and GCF?

For two numbers, the product of the LCM and the GCF equals the product of the numbers: LCM × GCF = a × b. For 12 and 18, 36 × 6 = 216 = 12 × 18. That gives a shortcut, LCM = a × b / GCF. It works for two numbers only; with three or more you combine them two at a time.

Can an LCM calculator handle more than two numbers?

Yes. This one takes two to five numbers. It takes each prime to its highest power across all of them, which is the same as finding LCM(LCM(a, b), c) and so on. For 4, 6 and 10 the answer is 2² · 3 · 5 = 60.

Where is the LCM used in real life?

It finds common denominators for adding fractions, and it tells you when repeating events line up again. Two buses that leave every 12 and every 18 minutes depart together every 36 minutes. It also sizes packages so nothing is left over: hot dogs sold in 10s and buns in 8s match up at 40 of each.

Why is the LCM important?

It is the key step in adding and subtracting fractions with different denominators, since the LCM gives the smallest common denominator. It also solves scheduling and cycle problems, such as when gears with different tooth counts return to their starting positions together.

What is the least common denominator?

The least common denominator (LCD) of fractions is the LCM of their denominators. For 1/4 and 1/6 the LCD is 12, so they become 3/12 and 2/12. Enter the denominators here, and use the fraction calculator to add or subtract the fractions.

What is the LCM of two relatively prime numbers?

It is their product. Two numbers are relatively prime when their GCF is 1, and then LCM = a · b / 1. The LCM of 3 and 5 is 15, and the LCM of 8 and 9 is 72, even though 8 and 9 are not prime numbers themselves.

Why doesn't the calculator accept zero, negative numbers or decimals?

The LCM is defined for positive whole numbers here, and every common multiple of a set that includes 0 is 0, which is not useful. Enter whole numbers from 1 to 1,000,000. For a negative number, use its positive value: the LCM of -4 and 6 is the LCM of 4 and 6, which is 12.

Last updated: Responsible editor: Jared Alan
Checked against 28 test cases · How we test