GCD Calculator
Calculate the Greatest Common Divisor of two numbers.
What is the greatest common divisor?
The greatest common divisor, or GCD, is the largest whole number that divides two integers without leaving a remainder. You will also see it called the greatest common factor (GCF) or highest common factor (HCF), but they all mean the same thing. For example, the GCD of 12 and 18 is 6, because 6 is the biggest number that fits evenly into both.
It shows up most often when you simplify fractions, since dividing the top and bottom by their GCD reduces a fraction to its lowest terms.
How the calculator finds it
Behind the scenes it uses the Euclidean algorithm, which is far faster than checking every possible factor. The idea is simple: keep replacing the larger number with the remainder of dividing the two, and stop when the remainder hits zero. The last non-zero value is the GCD.
$$\gcd(a, b) = \gcd(b,\ a \bmod b)$$
How to use this calculator
- Enter the first number, \(a\).
- Enter the second number, \(b\).
- Click calculate to find \(\gcd(a,b)\).
- Use the result to simplify fractions or compare factors.
The formula explained
The formula \(\gcd(a,b)=\gcd(b, a \bmod b)\) is the Euclidean algorithm. It keeps replacing the pair with a smaller remainder until the remainder is 0, and the last nonzero value is the GCD.
- a = the first number
- b = the second number
- \(a \bmod b\) = the remainder when \(a\) is divided by \(b\)
Step by step method
- List the divisors of both numbers or use repeated division.
- Find the largest number that appears in both divisor lists.
- Or use the Euclidean algorithm by dividing and taking remainders until the remainder is 0.
Worked example
Problem. Find the GCD of 48 and 18.
- Divide 48 by 18, which gives a remainder of 12, so \(\gcd(48,18)=\gcd(18,12)\).
- Divide 18 by 12, which gives a remainder of 6, so \(\gcd(18,12) = \gcd(12,6)\).
- Divide 12 by 6, which gives a remainder of 0, so the GCD is 6.
Answer. \(\gcd(48,18)=6\)
Tips and common mistakes
- If one number is 0, the GCD is the other number, as long as it is not 0.
- Make sure you are finding the greatest common divisor, not the least common multiple.
Frequently asked questions
Is GCD the same as GCF or HCF?+
Yes. Greatest common divisor, greatest common factor, and highest common factor are three names for exactly the same idea. Different textbooks just prefer different wording.
What is the GCD if one number is zero?+
The GCD of any number and zero is the number itself, because every integer divides zero. So gcd(7, 0) is 7.
How does GCD relate to LCM?+
They are linked by a neat rule: for any two positive integers, their GCD times their LCM equals the product of the two numbers. So once you know one, you can find the other.
More Mathematics Tools
Explore related calculators in this category
Absolute Value Calculator
Calculate the absolute value of any number. Use this free calculator for fast, accurate answers, complete with the formula and a worked example.
Absolute Value Equation Solver
Solve equations of the form |ax + b| = c.
Adding Fractions Calculator
Add two fractions with step-by-step simplification.
One-Way ANOVA Calculator
Perform one-way ANOVA on multiple groups.
You Might Also Like
Popular tools from other categories
AC to DC Converter Calculator
Convert AC voltage to DC voltage for different rectifier configurations. Free online calculator with instant, step-by-step results.
Acid-Base Titration Calculator
Calculate concentration from titration data. Get quick, accurate results with this free online calculator, including formulas and worked examples.
ABV Calculator
Calculate alcohol by volume from original and final gravity. Free calculator with instant calculations, the underlying formula, and an easy-to-follow example.
Amortization Schedule Calculator - Free Online
Free Generate a complete amortization schedule. Step-by-step solutions and formulas included. Free, accurate results with step-by-step explanations.
Can't Find the Right Calculator?
Try our AI Math Solver, type any problem in plain English and get instant step-by-step solutions.