GCD and LCM Calculator
The greatest common divisor (GCD) is the largest number that divides all of the given numbers exactly, while the least common multiple (LCM) is the smallest number that is a multiple of all of them. The GCD is what you use to reduce fractions; the LCM is what you use to put fractions over a common denominator and to find when periodic events coincide.
This calculator handles more than two numbers as well: just paste the values separated by commas, spaces, or line breaks. Along with the results it gives a table showing the prime factorization of every number and of the GCD and LCM themselves, and when exactly two numbers are entered it also verifies GCD × LCM = a × b.
Formula
GCD: multiply the SMALLEST powers of the shared prime factors LCM: multiply the LARGEST powers of all the prime factors For two numbers: GCD(a, b) × LCM(a, b) = a × b Euclidean algorithm: GCD(a, b) = GCD(b, a mod b)
The identity GCD × LCM = a × b holds ONLY for two numbers; it cannot be used as a check with three or more. Another common error is taking the larger exponents for the GCD: the GCD uses the smaller exponents, the LCM the larger ones.
How to Calculate
- Type your numbers into the box — commas, spaces, or line breaks all work as separators.
- Make sure you have entered at least 2 and at most 20 positive integers.
- Read the GCD and LCM results; if you entered two numbers, the GCD × LCM check appears in the interpretation.
- Use the table to inspect the prime factorization of every input and of the two results.
Worked Examples
12 and 18
Since 12 = 2² × 3 and 18 = 2 × 3², the GCD takes the smaller exponents and gives 2 × 3 = 6, while the LCM takes the larger ones and gives 2² × 3² = 36. Check: 6 × 36 = 216 = 12 × 18.
GCD — greatest common divisor: 6 · LCM — least common multiple: 36 · Count of numbers entered: 2
Three numbers: 4, 6, and 8
For 4 = 2², 6 = 2 × 3, and 8 = 2³, the largest number dividing all three is GCD = 2; the smallest of their common multiples is LCM = 2³ × 3 = 24.
GCD — greatest common divisor: 2 · LCM — least common multiple: 24 · Count of numbers entered: 3
Bus departure problem: 15, 25, and 35
Three buses leaving every 15, 25, and 35 minutes will depart together again LCM(15, 25, 35) = 525 minutes after their first joint departure. The GCD of these numbers is 5.
GCD — greatest common divisor: 5 · LCM — least common multiple: 525 · Count of numbers entered: 3