MATMathematics

GCD & LCM

Calculate the Greatest Common Divisor (GCD) and Least Common Multiple (LCM) of two numbers. See step-by-step Euclidean algorithm.

Try an example

How It Works

Formula

GCD(a,b)=GCD(b,  amodb)\text{GCD}(a,b) = \text{GCD}(b,\; a \bmod b)

LCM(a,b)=a×bGCD(a,b)\text{LCM}(a,b) = \frac{a \times b}{\text{GCD}(a,b)}

Where

aa

First positive integer

bb

Second positive integer

The GCD is found using the Euclidean algorithm: repeatedly divide the larger number by the smaller and take the remainder, until the remainder is 0. The last non-zero remainder is the GCD. The LCM is then calculated from the GCD-LCM product identity.

Frequently Asked Questions

Related Calculators

Ready to Calculate?

Free calculators.