GCD Calculator
Find the greatest common divisor (GCD, also called GCF or HCF) of two or more numbers, with every step of the Euclidean algorithm.
Enter at least two whole numbers, separated by commas or spaces.
These numbers are coprime: their only common divisor is 1.
Euclidean algorithm
Runs in your browser. What you enter is kept for 30 days to improve Toolgrid, then deleted.
How to use the GCD Calculator
- 1 Type two or more whole numbers, separated by commas or spaces.
- 2 The greatest common divisor appears immediately.
- 3 Follow the steps of the Euclidean algorithm to see how it was found.
About the GCD Calculator
The greatest common divisor (GCD) of two numbers is the largest whole number that divides both without a remainder. The GCD of 48 and 180 is 12. It is also called the greatest common factor (GCF) or highest common factor (HCF).
The calculator uses the Euclidean algorithm: divide the larger number by the smaller, then keep dividing the previous divisor by the remainder until the remainder is 0. The last non-zero remainder is the GCD. For 180 and 48: 180 = 3 × 48 + 36, 48 = 1 × 36 + 12, 36 = 3 × 12 + 0, so the GCD is 12. With more than two numbers, the GCD of the first two is combined with the third, and so on.
The GCD is used to simplify fractions (divide numerator and denominator by their GCD), to split things into equal groups, and in many areas of number theory and cryptography. Two numbers whose GCD is 1 are called coprime.
Frequently asked questions
What is the GCD of 0 and a number?
gcd(0, n) = n, because every number divides 0. The GCD of 0 and 0 is defined as 0.
How is the GCD related to the LCM?
For two positive numbers a and b: gcd(a, b) × lcm(a, b) = a × b. For 4 and 6: 2 × 12 = 24.
What does coprime mean?
Two numbers are coprime (relatively prime) when their only common divisor is 1, such as 8 and 15. Neither has to be prime itself.
Can I use negative numbers?
Yes. The GCD is always given as a positive number: gcd(−12, 18) = 6.
How do I simplify a fraction with the GCD?
Divide the numerator and the denominator by their GCD. For 48/180, the GCD is 12, so the fraction simplifies to 4/15.