Whether your textbook calls it the greatest common factor (GCF), the highest common factor (HCF) or the greatest common divisor (GCD), it is the same number: the largest whole number that divides every number in a set without a remainder. You need it to simplify fractions and ratios, to cut materials into the largest equal pieces, and in cryptography and computer science.
This guide explains the idea, compares the two main methods, and spends most of its time on Euclid's algorithm, a 2,300-year-old procedure that is still the fastest way to find the GCD of large numbers. All examples were verified with our calculator.
What the greatest common factor is
The factors of 84 are 1, 2, 3, 4, 6, 7, 12, 14, 21, 28, 42 and 84. The factors of 126 are 1, 2, 3, 6, 7, 9, 14, 18, 21, 42, 63 and 126. The largest number in both lists is 42, so GCF(84, 126) = 42.
Listing factors works for small numbers but quickly becomes impractical. Two better methods follow.
Method 1: prime factorisation
Write each number as a product of primes, then multiply the primes they all share, each at its lowest power.
84 = 2² × 3 × 7
126 = 2 × 3² × 7
210 = 2 × 3 × 5 × 7
The primes common to all three are 2, 3 and 7. Their lowest powers are 2¹, 3¹ and 7¹, so GCF(84, 126, 210) = 2 × 3 × 7 = 42.
This method is clear and handles several numbers at once; the Prime Factorization Calculator will do the splitting if the numbers are awkward. Its weakness is that factoring large numbers is slow, sometimes extremely slow.
Method 2: Euclid's algorithm
Euclid's algorithm avoids factoring altogether. It rests on one fact: the GCD of two numbers also divides their difference, and therefore the remainder when one is divided by the other. So you can keep replacing the larger number with that remainder until the remainder is zero.
The procedure:
- Divide the larger number by the smaller and note the remainder.
- Replace the larger number with the smaller, and the smaller with the remainder.
- Repeat until the remainder is 0. The last non-zero remainder is the GCD.
Example: GCD(1071, 462)
1071 = 2 × 462 + 147
462 = 3 × 147 + 21
147 = 7 × 21 + 0
The last non-zero remainder is 21, so GCD(1071, 462) = 21. Three lines, no factoring.
The algorithm is fast because the numbers shrink quickly: the remainder at least halves every two steps. Even for numbers with dozens of digits it finishes in a few hundred steps at most.
For more than two numbers, apply it pair by pair: GCD(84, 126, 210) = GCD(GCD(84, 126), 210) = GCD(42, 210) = 42.
Bézout's identity and the extended algorithm
Running Euclid's algorithm backwards gives something extra. For any two whole numbers a and b, there are integers x and y such that:
a × x + b × y = GCD(a, b)
This is Bézout's identity. For the example above:
1071 × (−3) + 462 × 7 = −3213 + 3234 = 21
And for 84 and 126: 84 × (−1) + 126 × 1 = 42.
The coefficients are found by the extended Euclidean algorithm. They matter in number theory and computing: they are how modular inverses are calculated, which RSA encryption relies on, and they tell you whether an equation like 84x + 126y = 50 has whole-number solutions (it does not, because 50 is not a multiple of 42).
Practical uses of the GCF
Simplifying fractions and ratios
Divide the top and bottom by their GCF: 84 ÷ 42 = 2 and 126 ÷ 42 = 3, so 84/126 = 2/3. The Fraction Calculator does this automatically after every operation. The same works for a ratio such as 84 : 126 = 2 : 3. For more on ratios, see simplifying ratios and solving proportions.
The largest equal pieces
A floor measures 360 cm by 150 cm and you want the largest square tiles that fit exactly with no cutting. GCF(360, 150) = 30, so 30 cm tiles, 12 across and 5 down.
Grouping without leftovers
If you have 84 pens, 126 notebooks and 210 folders and want identical packs with nothing left over, the most packs you can make is 42, each with 2 pens, 3 notebooks and 5 folders.
Coprime numbers
Two numbers with GCF 1 are coprime (or relatively prime), such as 8 and 15. Neither needs to be prime itself. Coprime pairs matter for gear design, where they spread wear evenly across the teeth, and for fractions, which are in lowest terms exactly when the numerator and denominator are coprime.
How to use the GCF Calculator
- Open the GCF Calculator.
- Enter your numbers in Numbers (2 or more), separated by commas or spaces. Up to 30 whole numbers of up to 60 digits each are accepted.
- Read the Greatest common factor (GCF / GCD / HCF). The card also says whether the numbers are Coprime?, gives their Least common multiple (LCM) and, for exactly two numbers, the Bézout identity (extended Euclid).
- Look at the factor table under the input for each number's prime factorisation.
- Open the steps to see every division of Euclid's algorithm, followed by a prime factorisation check.
Negative numbers are handled by using their absolute values, since signs do not affect the GCF.
Other ways to find it
- Spreadsheets:
=GCD(84,126,210)returns 42 in Excel, Google Sheets and LibreOffice. - Programming: Python's
math.gcd(84, 126, 210)accepts several arguments in version 3.9 and later. Most languages have a built-in GCD or make it a five-line function. - By hand: use Euclid for two numbers of any size, and prime factors when the numbers are small or you also need the LCM. The LCM Calculator covers the other half of the pair.
Common mistakes
Taking the highest powers
Highest powers of every prime give the LCM. The GCF uses only primes common to all numbers, at their lowest power.
Reading the wrong line of Euclid
Keep dividing until a remainder is exactly 0, then take the remainder from the line before it. In the 1071 and 462 example that is 21, not 147 and not 7 (the quotient on the last line).
Thinking coprime means prime
8 and 15 are both composite but share no factor other than 1, so they are coprime.
Treating 0 carelessly
GCF(0, 12) = 12, because every number divides 0. GCF(0, 0) is undefined. The calculator follows these rules.
Frequently asked questions
Are GCF, GCD and HCF the same thing?
Yes. Greatest common factor, greatest common divisor and highest common factor are three names for the same number; which one you see depends on country and textbook.
What is the fastest way to find the GCD of two large numbers?
Euclid's algorithm. It needs only division with remainder, never factoring, and finishes in a small number of steps even for numbers with many digits.
How do I find the GCF of three numbers?
Find the GCF of the first two, then the GCF of that result with the third. For 84, 126 and 210 that is GCF(42, 210) = 42.
What does it mean if the GCF is 1?
The numbers are coprime: they share no factor except 1. A fraction whose numerator and denominator are coprime is already in lowest terms.
What is Bézout's identity used for?
It shows the GCD can be written as a combination of the two numbers. The coefficients give modular inverses, which are used in cryptography and in solving equations in whole numbers.