GCD Calculator

Calculate the greatest common divisor of multiple numbers.

Runs locally in your browser

Your inputs are processed locally in your browser and are not uploaded or stored by us.

For values that are not all zero, the GCD is the greatest positive integer that divides every value without remainder. This calculator defines gcd(0, 0) = 0 according to its shared integer-math contract.

How to use the GCD Calculator

  1. Enter two or more integer values in the input fields.
  2. Click "Add value" if you need to calculate the GCD for more than two numbers.
  3. Click "Calculate" to find the greatest common divisor for all provided values.

Euclidean Algorithm

GCD(a, b) = GCD(b, a mod b)

The tool uses the Euclidean algorithm or repeated shared-GCD reduction across all values. It calculates the GCD iteratively by working through the magnitude of the integers. Input signs do not make the GCD negative because the calculation uses absolute magnitudes.

Calculating GCD for 24, 36, and 60

Values24, 36, 60
gcd(24, 36) = 12 gcd(12, 60) = 12
Result: 12

Notes

  • The calculator requires at least 2 values to compute a result.
  • Inputs must fit within JavaScript’s safe-integer range.
  • Negative integers are allowed (e.g., gcd(-12, 18) = 6).
  • Zero is allowed (e.g., gcd(0, 5) = 5 and gcd(0, 0) = 0).
  • Decimal values are rejected; the calculator preserves exact integer relationships within its documented limits.
  • Your inputs are processed locally in your browser and are not uploaded or stored by us.