LCM and GCD calculator with steps
The least common multiple (LCM) answers when repeating cycles line up again; the greatest common divisor (GCD) finds the largest equal unit that divides values without a remainder. Enter 2 to 8 positive whole numbers from 1 to 1 billion.
Calculate
Problems LCM and GCD can solve
- LCM — repeating cycles: if one bus arrives every 12 minutes and another every 18, their schedules coincide every 36 minutes.
- LCM — adding fractions: 1/12 + 1/18 uses 36 as a common denominator, giving 3/36 + 2/36 = 5/36.
- GCD — cutting equal pieces: the largest equal pieces from 12 m and 18 m lengths are 6 m.
- GCD — reducing fractions: divide 12/18 by GCD 6 to get 2/3.
How the calculation works
The prime-factorization method writes each input as a product of primes. The LCM takes the highest exponent of every prime that appears; the GCD takes only the primes shared by all values, at their lowest exponent. The Euclidean algorithm is another efficient way to find a GCD: repeatedly replace a pair by the smaller value and the remainder until the remainder is zero.
Worked example: 12 and 18
12 = 2² × 3 and 18 = 2 × 3². For the LCM, take the largest exponent of each prime: 2² × 3² = 36. For the GCD, take the shared primes with the smallest exponents: 2 × 3 = 6. For two numbers only, LCM × GCD = their product.
A common mix-up
For the LCM, use the largest exponent of each prime, including primes present in only one number. For the GCD, use only common primes and the smallest shared exponent.
Frequently asked questions
What is the relationship between LCM and GCD?
For two positive integers a and b, LCM(a,b) × GCD(a,b) = a × b. This identity does not extend by simply multiplying the LCM and GCD of three or more values.
What is the LCM of coprime numbers?
If the GCD is 1, the least common multiple is the product. For example, 8 and 15 are coprime, so their LCM is 120.
Can I use this calculator with fractions?
No. This tool accepts positive whole numbers. Fraction operations require a separate method; use the fraction calculator for arithmetic with fractions.
Can the GCD be larger than either input?
No. The GCD is at most the smallest input; the LCM is at least the largest input.