GCD and LCM

Use integer divisibility

GCD finds the largest common divisor of the absolute input values. The Euclidean algorithm repeatedly replaces a pair by its divisor and remainder until the remainder is zero.

For nonzero inputs, LCM uses abs(a×b)/gcd(a,b), with cancellation before the product. Both answers are nonnegative. This calculator returns zero for GCD(0,0), and LCM is zero whenever either input is zero.

Worked example: GCD(−18,24) = 6

Signs do not change the positive common divisors. Divide 24 by 18: 24=18×1+6. Divide 18 by 6: 18=6×3+0. The last nonzero remainder is 6.

For LCM(−6,8), GCD is 2. The least common multiple is 6×8/2=24.

Load example fills the form without calculating. Choose its primary action to work it out.

Sources and related calculators

The method and worked example here are original. Sources describe the underlying mathematics or notation; calculation choices and limits are in the precision and syntax guide.