OmniTools
mathDifficulty: 2/5

GCD and LCM Calculator

Find the greatest common divisor and least common multiple of two or more integers, with prime factorisations and the Euclidean steps.

Why BigInt: The GCD and LCM are computed with BigInt, so the greatest common divisor of two 30-digit numbers is exact here. An ordinary JavaScript number cannot represent integers above 9,007,199,254,740,991 (253 − 1) precisely — past that point it silently rounds, so a calculator built on ordinary numbers returns a wrong answer for large inputs rather than an error. Here the answer is exact, whatever the size.

How it works

  1. Enter at least two whole numbers, separated by commas, spaces or new lines.
  2. The greatest common divisor and least common multiple update live, with the prime factorisation of every value.
  3. Everything is computed exactly with BigInt in your browser — a 30-digit input is as exact as 12.
Privacy & Processing: Everything runs in your browser. Nothing you enter is uploaded, stored, or sent to analytics.

Frequently Asked Questions

How many numbers can I enter?

Two or more. The GCD and LCM are computed across every value, not just the first pair.

Does it show the working?

Yes. The Euclidean algorithm steps are listed for the first pair, and prime factorisations are given for each value when they are small enough to factor quickly — which is what makes the answer checkable rather than just asserted.

How large can the numbers be?

Up to 1000 digits. Arithmetic is arbitrary-precision, so a 30-digit GCD is exact. Prime factorisation is only attempted below about a trillion, since trial division beyond that is impractical in a browser — the GCD and LCM are still exact.

What if I enter a decimal?

It is refused rather than truncated. Rounding 7.9 to 7 would answer a different question than the one you asked, and GCD is defined only for integers.

Related Tools