Randomly

Greatest common divisor

Type two or more integers to get their greatest common divisor, with the least common multiple one click away.

Input

Greatest common divisor

Need ≥ 2

Enter at least two integers to find their GCD.

Outputs
GCD · LCM
Precision
Exact

Related tools

This greatest common divisor calculator takes a list of whole numbers, separated by commas, spaces or new lines, and shows the GCD as you type. The least common multiple sits under Show LCM. Both are worked out with the Euclidean algorithm on BigInt values, so a 40-digit input is handled as exactly as 12 and 18. Anything that isn't a whole number, like 2.5 or abc, is skipped, and the skipped entries are listed under Show LCM.

How to calculate the greatest common divisor

  1. Enter at least two integers, for example 12, 18, 30.
  2. The GCD appears right away. Click it, or Copy GCD, to copy it.
  3. Open Show LCM to see the least common multiple. Click the LCM to copy it.

The Euclidean algorithm

Replace the pair (a, b) with (b, a mod b) and repeat until the remainder is zero. Whatever is left is the GCD. For 48 and 18: (48, 18) → (18, 12) → (12, 6) → (6, 0), so the GCD is 6. With three or more numbers the tool works along the list: the GCD of the first two, then the GCD of that result and the third, and so on. The LCM comes from the GCD, LCM(a, b) = |a × b| ÷ GCD(a, b), applied along the list the same way.

Frequently asked questions

What is the greatest common divisor (GCD)?

The largest positive integer that divides every number in the set with no remainder. GCD(12, 8) = 4.

What is the least common multiple (LCM)?

The smallest positive integer that every number in the set divides into. LCM(4, 6) = 12. If any input is 0, the LCM shown is 0.

Can I enter more than two numbers?

Yes, as many as you like. For 12, 18 and 30 the GCD is 6 and the LCM is 180.

What about negative numbers?

The sign is ignored, so GCD(-12, 18) = 6, the same as for 12 and 18.

Does this handle large numbers accurately?

Yes. Inputs are read as BigInt, so there's no floating-point rounding at any size.

Built and maintained by Bipul Kumar. Found a wrong number or a broken result? Tell me and I'll fix it.