Math Calculators

GCD & LCM Calculator

Find the greatest common divisor and least common multiple.

Rate this tool

How to use the GCD & LCM Calculator

  1. Enter two whole numbers.
  2. See their greatest common divisor and least common multiple.
Formula GCD via Euclid’s algorithm · LCM = a × b ÷ GCD

About the GCD & LCM Calculator

Enter two whole numbers and this calculator returns their greatest common divisor — the largest number that divides both exactly — and their least common multiple, the smallest number both divide into. The GCD is found with Euclid’s algorithm, and the LCM comes from it almost free, via the identity |a × b| ÷ GCD.

Euclid’s algorithm is one of the oldest algorithms still in daily use, and it is elegant because of what it avoids: it never factorises anything. It rests on a single observation — any number dividing both a and b must also divide their remainder — so you replace the pair (a, b) with (b, a mod b) and repeat until the remainder hits zero. Whatever is left is the GCD. Finding the GCD of 1,071 and 462 takes four steps; factorising them would take far longer, and for large numbers factorisation becomes hopeless while Euclid stays fast.

The practical uses are everywhere fractions are. The GCD is what reduces 18/24 to 3/4 and what simplifies a ratio to its lowest terms — see the ratio calculator, which does exactly this internally. The LCM is what you need for a common denominator when adding fractions, and for “when do these two cycles line up again?” scheduling questions. If you want the prime factors themselves, try the prime number calculator.

Frequently asked questions

What is the GCD used for?

Most commonly for reducing fractions and ratios to their simplest form — dividing the top and bottom by their GCD is exactly what “lowest terms” means. It also shows up in scheduling and cryptography.

How does Euclid’s algorithm work?

Divide the larger number by the smaller and keep the remainder. Then repeat with the smaller number and that remainder. When the remainder reaches zero, the last non-zero value is the GCD. No factorisation needed.

How are the GCD and LCM related?

GCD × LCM = |a × b| for any two non-zero integers. That is why this page can compute the LCM instantly once the GCD is known.

Can I use negative numbers or decimals?

Negative numbers work — the GCD is taken from their absolute values. Decimals do not: both inputs are read as whole numbers, and neither can be zero, since every number divides zero.

What if the GCD is 1?

The numbers are coprime — they share no factor other than 1, like 16 and 9. Their ratio is already in lowest terms and their LCM is simply their product.