Math / GCD & LCM
GCD & LCM calculator
Calculate the greatest common divisor and least common multiple of two whole integers, including negative and zero values.
Formula: GCD uses the Euclidean algorithm. LCM is |a × b| ÷ GCD(a, b), with LCM equal to zero when either input is zero.
The basics
Divisors, multiples, and the Euclidean algorithm
The greatest common divisor is the largest number that divides both inputs evenly; the least common multiple is the smallest number both inputs divide into. The two are linked: GCD × LCM equals the product of the absolute values, which is how this tool derives the LCM once the GCD is known.
GCD is the same divisor used to reduce fractions and ratios, so the Fraction calculator and the Ratio Simplifier rely on it under the hood.
How the formula works
LCM(a, b) = |a × b| ÷ GCD(a, b)
The Euclidean algorithm finds the GCD by repeated remainder division; the LCM follows from the product rule above.
The LCM is zero when either input is zero, following the standard convention.
Signs are ignored; the divisor and multiple are positive.
Keep exploring
In practice
Worked examples
Input
−24, 18
Answer
GCD = 6; LCM = 72
Input
0, 9
Answer
GCD = 9; LCM = 0
Good to know
Frequently asked questions
Keep going