GCD and LCM Calculator

The greatest common divisor and least common multiple of two numbers or of a whole list.

Runs entirely in your browser. Nothing is uploaded, logged or stored.

Two or more, separated by commas or spaces.

Greatest common divisor

6

Least common multiple
72
Coprime?
no
The divisor, factorised
2 × 3

The greatest common divisor is the largest number that divides all of them; the least common multiple is the smallest number they all divide into. One reduces a fraction, the other finds the common denominator.

How it works

The divisor comes from Euclid's algorithm: replace the larger number by its remainder on division by the smaller, and repeat until one of them is zero. It is over two thousand years old and still the fastest way — a handful of steps even for numbers with twelve digits.

The multiple is the product divided by the divisor, but divided first and multiplied afterwards. Multiplying first overflows a machine integer long before the answer itself would, and the division is always exact so the order costs nothing.

A list of more than two is folded pairwise, which is correct because both operations are associative: the divisor of a, b and c is the divisor of a and the divisor of b and c.

Examples

Case Input Result
Two numbers 48, 18 GCD 6, LCM 144
A whole list 12, 18, 24 GCD 6, LCM 72
Nothing in common 8, 15 GCD 1 — coprime

Frequently asked questions

What does coprime mean?

That the greatest common divisor is 1: the numbers share no factor at all. They need not be prime themselves — 8 and 15 are coprime and neither is prime.

What happens if one of the numbers is zero?

The divisor of 0 and n is n, because every number divides zero. The multiple is 0, because zero is the only multiple zero has. Both follow from the definitions rather than being special cases.

Does the sign matter?

No. Both are reported as positive numbers, which is the usual convention: −12 and 12 have exactly the same divisors.

Good to know

  • Up to fifty numbers, each below a thousand billion. The ceiling is where factorising the divisor still returns inside a page load.

All Mathematics tools