LCM Calculator
Enter two to ten whole numbers and this LCM calculator returns their least common multiple and greatest common factor, with the prime factorization steps.
Results
- Least common multiple (LCM)
- -
- Greatest common factor (GCF)
- -
This result is larger than 9,007,199,254,740,991, the limit for ordinary JavaScript numbers. It was calculated with exact big-integer arithmetic, so every digit is correct.
Steps (prime factorization method)
1. Prime factors of each number
2. Powers of each prime
3. Combine
At least one number is larger than 1 trillion, so the prime factorization steps are skipped. The LCM and GCF above are still exact and come from the Euclidean algorithm.
How to use the LCM calculator
- Type two to ten positive whole numbers in the box. Separate them with commas, spaces or line breaks.
- The least common multiple and greatest common factor appear immediately. There is no calculate button to press.
- Open the steps underneath to see each number written as a product of primes, a table of the prime powers, and how the LCM and GCF are built from that table.
- Use the copy button to grab both answers, or Reset to start over.
How the LCM is found
The least common multiple of a set of numbers is the smallest positive number that each of them divides evenly. Two methods are common. The calculator shows the first and uses the second to guarantee exact answers for very large inputs.
- Prime factorization: factor every number into primes. For each prime that appears anywhere, keep its highest power, and multiply those powers together to get the LCM. Keep its lowest power (zero if a number lacks that prime) to get the GCF.
- Euclidean algorithm: find GCF(a, b) by repeated division, then use
LCM(a, b) = a ÷ GCF(a, b) × b. For more than two numbers, apply it step by step: LCM(a, b, c) = LCM(LCM(a, b), c).
Worked example 1: LCM and GCF of 4, 6 and 8
Factor each number: 4 = 2², 6 = 2 × 3, and 8 = 2³. The highest power of 2 is 2³ and the highest power of 3 is 3¹, so the LCM is 2³ × 3 = 8 × 3 = 24. For the GCF, the lowest power of 2 is 2¹ and 3 is missing from 4 and 8, so it drops out. The GCF is 2. As a check, 24 ÷ 4 = 6, 24 ÷ 6 = 4 and 24 ÷ 8 = 3, all whole numbers.
Worked example 2: LCM and GCF of 12, 18 and 30
Here 12 = 2² × 3, 18 = 2 × 3², and 30 = 2 × 3 × 5. The highest powers are 2², 3² and 5, so the LCM is 4 × 9 × 5 = 180. The lowest powers are 2 and 3, and 5 is missing from 12 and 18, so the GCF is 2 × 3 = 6. Check: 180 ÷ 12 = 15, 180 ÷ 18 = 10, and 180 ÷ 30 = 6.
Where the LCM is useful
- Adding or subtracting fractions: the least common denominator of 1/4, 1/6 and 1/8 is 24.
- Repeating schedules: if one event happens every 4 days, another every 6 days and a third every 8 days, they all line up every 24 days.
- Simplifying ratios, where the GCF is the number you divide both sides by.
Limits
The tool accepts 2 to 10 positive whole numbers of up to 30 digits. It uses big-integer arithmetic, so results stay exact even above 9,007,199,254,740,991, the largest integer that ordinary JavaScript numbers can store without rounding. The prime factorization steps are shown when every input is 1 trillion or less, because factoring huge numbers by trial division would make the page slow. For larger inputs the LCM and GCF are still exact.
Frequently asked questions
What is the least common multiple?
The least common multiple (LCM) of a set of whole numbers is the smallest positive number that every number in the set divides into evenly. For 4, 6 and 8 it is 24, because 24 is the first number that appears in the multiplication tables of all three.
How do I find the LCM using prime factorization?
Write each number as a product of primes, then for every prime that appears take its highest power from any of the numbers, and multiply those together. For 4 (2 x 2), 6 (2 x 3) and 8 (2 x 2 x 2), the highest power of 2 is 2 cubed and the highest power of 3 is 3, so the LCM is 8 x 3 = 24.
What is the difference between LCM and GCF?
The LCM is the smallest number all inputs divide into, so it is at least as large as the biggest input. The greatest common factor (GCF, also called GCD or HCF) is the largest number that divides all inputs, so it is no larger than the smallest input. For two numbers a and b, LCM x GCF = a x b.
How many numbers can I enter, and how big can they be?
You can enter 2 to 10 positive whole numbers of up to 30 digits each. The tool uses exact big-integer arithmetic, so results beyond the ordinary JavaScript safe limit of 9,007,199,254,740,991 stay correct. Step-by-step prime factorization is shown only when every number is 1 trillion or smaller.
Can I use 0, negatives or decimals?
No. The LCM is defined here for positive whole numbers. Zero, negative numbers and decimals are rejected with a message so you can correct the entry.