GCD Calculator
Find the greatest common divisor of two whole numbers instantly. See the GCD, common factors and the Euclidean algorithm steps used to reach the answer.
Find the GCD of Two Numbers
Enter two whole numbers. ToolZippy finds their greatest common divisor using the Euclidean algorithm and shows the calculation steps below.
What Is a GCD?
The greatest common divisor (GCD) of two integers is the largest positive integer that divides both numbers without leaving a remainder.
For example, the common positive divisors of 48 and 18 include 1, 2, 3 and 6. The largest of these is 6, so:
GCD, GCF and HCF
You may see this same mathematical idea written using several different names:
- GCD — Greatest Common Divisor
- GCF — Greatest Common Factor
- HCF — Highest Common Factor
For two integers, these terms generally refer to the same value. So GCD(48,18), GCF(48,18) and HCF(48,18) are all 6.
How the GCD Calculator Works
ToolZippy uses the Euclidean algorithm. Instead of listing every factor of large numbers, the algorithm repeatedly divides and works with the remainder.
If the two non-negative numbers are a and b, with a ≥ b, the process repeatedly applies:
The last non-zero divisor is the GCD.
Example: GCD of 48 and 18
Start by dividing 48 by 18:
Now use 18 and 12:
Continue with 12 and 6:
Common GCD Examples
| First Number | Second Number | GCD | Why? |
|---|---|---|---|
| 12 | 18 | 6 | 6 is the largest factor shared by both. |
| 24 | 36 | 12 | Both numbers divide exactly by 12. |
| 54 | 24 | 6 | 6 is their greatest shared divisor. |
| 75 | 100 | 25 | 25 divides both values exactly. |
| 84 | 126 | 42 | 42 is the greatest common divisor. |
| 17 | 13 | 1 | The two numbers are coprime. |
Finding GCD by Listing Factors
For smaller numbers, another way to find the GCD is to list all positive factors of each number and identify the largest factor that appears in both lists.
For 24:
For 36:
Their common factors are 1, 2, 3, 4, 6 and 12. The greatest is 12, therefore GCD(24,36) = 12.
Using GCD to Simplify Fractions
One practical use of the GCD is reducing fractions to lowest terms. Find the GCD of the numerator and denominator, then divide both by that number.
For example, consider 18/24:
You can also use ToolZippy’s Fraction Simplifier to reduce a fraction automatically.
Using GCD With Ratios
The same idea can help reduce a ratio. For example, the ratio 18:24 has a GCD of 6. Dividing both terms by 6 gives:
What Does a GCD of 1 Mean?
If two positive integers have a GCD of 1, they have no positive common factor greater than 1. Such numbers are called coprime or relatively prime.
For example:
What Happens When One Number Is Zero?
For a non-zero integer a, the greatest common divisor of a and zero is the absolute value of a:
The special pair GCD(0,0) is not conventionally defined because every positive integer divides both zero values. This calculator therefore reports it as undefined.
Can the Calculator Use Negative Numbers?
Yes. The sign does not change the positive GCD. The calculator uses the absolute values of the entered integers.
Why Use the Euclidean Algorithm?
Listing factors works well for small values, but it becomes inefficient when the numbers are large. The Euclidean algorithm can find the GCD without generating every divisor first.
That makes it useful for quick manual calculations as well as computer implementations.
Input note: GCD is an integer concept on this calculator, so enter whole numbers rather than decimals. Negative integers are accepted and are handled using their absolute values. GCD(0,0) is reported as undefined.
GCD Calculator FAQs
What is the GCD of two numbers?
The GCD is the greatest positive integer that divides both numbers without leaving a remainder.
Are GCD, GCF and HCF the same?
In common elementary mathematics usage, GCD, GCF and HCF refer to the same concept: the largest positive integer that divides the given integers exactly.
What is the GCD of 48 and 18?
The GCD of 48 and 18 is 6. Both numbers are divisible by 6, and no larger positive integer divides both exactly.
How does the Euclidean algorithm find the GCD?
It repeatedly divides one number by the other and replaces the pair with the divisor and remainder. When the remainder reaches zero, the last non-zero divisor is the GCD.
Can the GCD be 1?
Yes. When the GCD of two positive integers is 1, the numbers are called coprime or relatively prime.
Can I calculate the GCD of negative numbers?
Yes. This calculator uses absolute values, so negative signs do not change the resulting positive GCD.
What is the GCD of a number and zero?
For a non-zero integer a, GCD(a,0) equals the absolute value of a. For example, GCD(18,0) = 18.
What is GCD(0,0)?
GCD(0,0) is conventionally undefined because there is no greatest positive common divisor; every positive integer divides zero.
Can I use decimals in a GCD calculation?
This calculator is designed for integers. Enter whole numbers rather than decimal values.
How is GCD used to simplify a fraction?
Find the GCD of the numerator and denominator, then divide both by that GCD. For example, the GCD of 18 and 24 is 6, so 18/24 reduces to 3/4.
