Randomly logo Randomly

Greatest common divisor

Enter two or more integers to find their greatest common divisor — and the least common multiple too. Euclidean algorithm in exact BigInt arithmetic.

Outputs GCD · LCM Precision Exact

Input

Greatest common divisor

Need ≥ 2

Enter at least two integers to find their GCD.

A free greatest common divisor (GCD) calculator that also computes the least common multiple (LCM) for two or more integers. Uses the Euclidean algorithm in exact BigInt arithmetic, so large numbers stay precise. Enter values separated by commas or spaces — results appear instantly in your browser.

How to calculate the greatest common divisor

  1. Enter two or more integers separated by commas or spaces.
  2. The GCD (largest number that divides all inputs evenly) is shown immediately.
  3. The LCM (smallest number divisible by all inputs) appears alongside it.
  4. Click either result to copy it.

The Euclidean algorithm

The Euclidean algorithm finds the GCD by repeatedly replacing the larger number with the remainder of dividing the two numbers, until the remainder is zero — at which point the other number is the GCD. For example: GCD(48, 18) → GCD(18, 12) → GCD(12, 6) → GCD(6, 0) = 6. The LCM follows from GCD: LCM(a, b) = |a × b| ÷ GCD(a, b). BigInt arithmetic ensures this stays exact even for very large inputs.

Frequently asked questions

What is the greatest common divisor (GCD)?

The GCD of a set of integers is the largest positive integer that divides all of them without a remainder. GCD(12, 8) = 4.

What is the least common multiple (LCM)?

The LCM is the smallest positive integer divisible by all values in the set. LCM(4, 6) = 12. It is computed from the GCD using LCM(a, b) = |a × b| ÷ GCD(a, b).

Can I enter more than two numbers?

Yes. The GCD is computed iteratively: GCD of the first two, then GCD of that result with the third, and so on.

Does this handle large numbers accurately?

Yes, BigInt arithmetic is used throughout, so there is no floating-point rounding regardless of input size.

Other tools