Greatest common divisor calculator

Enter two integers with up to 100 digits each to find their exact greatest common divisor.

First integer a
Second integer b

Greatest common divisor

6

|a| / GCD8
|b| / GCD3
CoprimeNo

How the GCD calculator works

Two rows divided into the largest equal groups

Enter two integers. The calculator finds their greatest common divisor and can reveal every division in the Euclidean algorithm.

Finding the largest shared factor

The GCD is the largest positive integer that divides both numbers without a remainder. Signs do not affect divisibility, so the calculation uses the absolute values of the inputs.

gcd(a,b)=gcd(b,amodb)\gcd(a,b)=\gcd(b, a\bmod b)

Each pass replaces the larger pair with the divisor and remainder. When the remainder reaches zero, the last nonzero divisor is the answer.

  1. Enter whole numbers in both fields.
  2. Read the prominent GCD and the two reduced quotients.
  3. Open the Euclidean algorithm when you want to audit the arithmetic.

Useful examples

48 and 18 give 6. They can be divided into six equal groups containing 8 and 3 items respectively.

84 and 126 give 42. The same result reduces the fraction 84/126 to 2/3.

17 and 31 give 1. A GCD of one means the numbers are coprime.

-54 and 24 give 6. The minus sign is ignored for the purpose of finding divisors.

Zero, large integers and interpretation

A GCD describes shared divisibility, not whether either input is prime.

Questions about greatest common divisors

What does a GCD of 1 mean?

The two integers are coprime: they share no positive divisor larger than one.

Can I enter negative integers?

Yes. The calculator uses absolute values, so changing a sign does not change the GCD.

Why is GCD(0, 25) equal to 25?

Every positive divisor of 25 also divides zero, so 25 is the greatest common divisor of the pair.

Is GCD(0, 0) really zero?

Mathematically the usual greatest positive divisor is not defined for this pair. The displayed zero is an explicit computing convention.

How does the GCD reduce a fraction?

Divide the numerator and denominator by their GCD. For 84/126, division by 42 gives 2/3.

Does the calculator round large values?

No. It uses exact integer arithmetic for inputs up to 100 digits.

Similar calculators

You may find the following calculators on the same topic useful:

Share on social media

If you liked it, please share the calculator on your social media platforms. It`s easy for you and beneficial for the project`s promotion. Thank you!