GCD & LCM Calculator
Find the largest number that divides every input and the smallest shared multiple in one calculation. Enter two numbers or a longer list. This is useful for reducing fractions, lining up repeating schedules, and checking how quantities can be divided evenly.
Loading the calculator. It runs in your browser, so JavaScript needs to be on.
How to use the GCD & LCM Calculator
- Enter integers in Whole numbers, separated by commas, spaces or line breaks.
- Keep negative signs if needed; the calculation uses absolute magnitudes. Include at least one nonzero value.
- Read Greatest common divisor at the top and Least common multiple below. Numbers included confirms how many entries were parsed.
The formula
Euclid's algorithm repeatedly replaces (a, b) with (b, a mod b) until b = 0. The remaining |a| is the GCD. For nonzero integers, LCM(a, b) = |a / GCD(a, b) × b|. Apply these operations across the list.
Worked example
For 12, 18 and 24, the greatest common divisor is 6 and the least common multiple is 72. Six divides all three values exactly. Seventy-two is divisible by all three: 72/12 = 6, 72/18 = 4 and 72/24 = 3.
GCD and LCM answer opposite questions
The GCD is a divisor shared by every input. It cannot exceed the smallest nonzero magnitude in the list. The positive LCM is a multiple shared by every nonzero input and cannot be smaller than the largest magnitude. For 8 and 12, those answers are 4 and 24. Confusing the two can produce a fraction denominator where you needed a reducing factor.
Use common divisors to reduce fractions
To reduce 12/18, divide both terms by their GCD of 6 and get 2/3. To add 1/12 and 1/18, use their LCM of 36 as a convenient common denominator. The first operation makes terms smaller; the second finds a common scale without unnecessarily multiplying the denominators.
Negative signs, zeros and exact arithmetic
Negative signs do not change common positive divisors or multiples. A list containing zero and a nonzero integer has an LCM of zero under this calculator's convention, and GCD(0, 6) = 6. An all-zero list is rejected. Inputs and exact intermediate multiples must fit the browser safe integer range, so extremely large LCMs produce an error rather than a rounded integer.
GCD & LCM Calculator questions
Is GCF the same as GCD?
Yes. Greatest common factor and greatest common divisor name the same positive integer.
What is the LCM of relatively prime numbers?
For two positive relatively prime numbers, the LCM is their product because their GCD is 1. For 5 and 7, the LCM is 35.
Can I use more than two numbers?
Yes. Enter the whole list, and the calculator combines the GCD and LCM successively across every entry.
Related calculators
- Fraction CalculatorEnter two fractions to add, subtract, multiply or divide. Get the reduced fraction, mixed...
- Prime Number CheckerEnter a whole number up to one trillion to check whether it is prime or composite....
- Ratio CalculatorEnter two ratio parts to simplify them, scale to a matching value or divide a total into...
- Binary CalculatorEnter two binary numbers to add, subtract, multiply or divide. See signed binary results,...