Least Common Multiple (LCM) Calculator
Find the least common multiple of 2 or more integers using prime factorization or the GCD method, with full step-by-step working.
LCM Calculator
You can enter up to 20 integers. Negative signs are allowed; zeros are ignored.
Result
LCM() =
Step-by-step solution
What is the least common multiple (LCM)?
The least common multiple (LCM) of a set of integers is the smallest positive integer that is a multiple of each number in the set.
For example, the multiples of 4 are 4, 8, 12, 16, 20, … and the multiples of 6 are 6, 12, 18, 24, …. The smallest number that appears in both lists is 12, so:
LCM(4, 6) = 12
LCM formulas
1. LCM using GCD (for two numbers)
Formula
\[ \text{LCM}(a,b) = \frac{|a \times b|}{\gcd(a,b)} \]
where \(\gcd(a,b)\) is the greatest common divisor of \(a\) and \(b\).
2. LCM of more than two numbers
\[ \text{LCM}(a_1, a_2, \dots, a_n) = \text{LCM}(\dots(\text{LCM}(\text{LCM}(a_1, a_2), a_3), \dots), a_n) \]
3. LCM using prime factorization
- Write each number as a product of prime factors.
- For each distinct prime, take the highest exponent that appears in any factorization.
- Multiply these prime powers together.
Example: LCM of 12 and 18
- 12 = \(2^2 \times 3^1\)
- 18 = \(2^1 \times 3^2\)
Take the highest power of each prime: \(2^2\) and \(3^2\). Then:
\(\text{LCM}(12, 18) = 2^2 \times 3^2 = 4 \times 9 = 36\)
Worked examples
Example 1 – LCM of 8, 12, and 20
Prime factorization method:
- 8 = \(2^3\)
- 12 = \(2^2 \times 3^1\)
- 20 = \(2^2 \times 5^1\)
Take the highest powers:
- Prime 2: max exponent = 3 → \(2^3\)
- Prime 3: max exponent = 1 → \(3^1\)
- Prime 5: max exponent = 1 → \(5^1\)
\(\text{LCM}(8, 12, 20) = 2^3 \times 3^1 \times 5^1 = 8 \times 3 \times 5 = 120\)
Example 2 – LCM of 15 and 28 using GCD
First find \(\gcd(15, 28)\). The common divisors are 1, so \(\gcd(15, 28) = 1\).
Then:
\(\text{LCM}(15, 28) = \dfrac{|15 \times 28|}{1} = 420\)
LCM vs GCD
The greatest common divisor (GCD) is the largest integer that divides all the numbers without remainder. The LCM is the smallest positive integer that all the numbers divide into.
For any non-zero integers \(a\) and \(b\), there is a key relationship:
\(\gcd(a,b) \times \text{LCM}(a,b) = |a \times b|\)
Common questions
Can LCM be negative?
By convention, the LCM is always taken as a positive integer. If you enter negative numbers, this calculator uses their absolute values.
What about zero?
The LCM is defined for non-zero integers. If one number is zero and the others are non-zero, some textbooks define the LCM as 0, but this is not very useful in practice. This tool ignores zeros and computes the LCM of the remaining non-zero integers. If all inputs are zero, it will show an error.
Why is LCM useful?
- Adding or comparing fractions with different denominators.
- Finding repeating cycles (e.g., schedules, signals, or periodic events).
- Solving Diophantine equations and number theory problems.
- Working with least common periods in trigonometry or discrete math.
LCM Calculator FAQ
What is the least common multiple (LCM)?
The least common multiple (LCM) of a set of integers is the smallest positive integer that is a multiple of each number in the set. For example, the LCM of 4 and 6 is 12 because 12 is the smallest number that both 4 and 6 divide evenly into.
How do you calculate LCM using prime factorization?
Factor each number into primes, then for each distinct prime take the highest exponent that appears in any factorization. Multiply these prime powers together to get the LCM. This calculator shows the prime factorization steps when you choose the “Prime factorization” method or when the numbers are small enough for the auto method to use it.
How do you find LCM using GCD?
For two numbers a and b, use the identity LCM(a,b) = |a × b| / GCD(a,b). For more than two numbers, apply this iteratively: LCM(a,b,c) = LCM(LCM(a,b), c), and so on. This is the method used by the “GCD-based” option in the calculator.
Can this LCM calculator handle negative numbers or zero?
Yes. Negative signs are ignored (the LCM is always positive). Zeros are ignored when computing the LCM; if all inputs are zero or no valid integers are entered, the calculator will show an error message instead of a result.
What is the difference between LCM and GCD?
The greatest common divisor (GCD) is the largest integer that divides all the numbers without remainder. The least common multiple (LCM) is the smallest positive integer that is a multiple of all the numbers. For any non-zero integers a and b, GCD(a,b) × LCM(a,b) = |a × b|.