GCF Calculator: Greatest Common Factor with Steps
GCF Calculator: Find the Greatest Common Factor with Steps
Enter two or more whole numbers to get their greatest common factor (GCF), with the work shown.
Your result
The GCF of 84, 126 and 210 is 42.
- GCF
- 42
- LCM
- 1,260
- Common factors
- 8
- Each number ÷ GCF
- 2, 3, 5
Common factors
- 1
- 2
- 3
- 6
- 7
- 14
- 21
- 42
How it was found
Steps: Euclid’s algorithm
Divide the bigger number by the smaller one, then divide by each remainder until the remainder is 0.
Start with GCF(84, 126)
- 126 = 84 × 1 + 42
- 84 = 42 × 2 + 0
The remainder is 0, so GCF(84, 126) = 42.
Then GCF(42, 210)
- 210 = 42 × 5 + 0
The remainder is 0, so GCF(42, 210) = 42.
So the GCF of all the numbers is 42.
Steps: prime factorization
- 84 = 2² × 3 × 7
- 126 = 2 × 3² × 7
- 210 = 2 × 3 × 5 × 7
| Prime | In 84 | In 126 | In 210 | Smallest power |
|---|---|---|---|---|
| 2 | 2² | 2¹ | 2¹ | 2¹ |
| 3 | 3¹ | 3² | 3¹ | 3¹ |
| 5 | none | none | 5¹ | not shared |
| 7 | 7¹ | 7¹ | 7¹ | 7¹ |
Multiply the shared primes: 2 × 3 × 7 = 42.
Steps: list the factors
Shared factors are highlighted.
- 84: 1, 2, 3, 4, 6, 7, 12, 14, 21, 28, 42, 84
- 126: 1, 2, 3, 6, 7, 9, 14, 18, 21, 42, 63, 126
- 210: 1, 2, 3, 5, 6, 7, 10, 14, 15, 21, 30, 35, 42, 70, 105, 210
The common factors are 1, 2, 3, 6, 7, 14, 21, 42. The greatest is 42.
What is the greatest common factor?
The greatest common factor (GCF) of two or more whole numbers is the largest number that divides all of them with no remainder. The GCF of 20 and 30 is 10.
You may also see it called the greatest common divisor (GCD) or the highest common factor (HCF). All three names mean the same number. GCF is common in school math, GCD in higher math and programming, and HCF in British and South Asian textbooks.
A common factor is any number that divides all of the numbers. 20 and 30 share the common factors 1, 2, 5 and 10. The greatest of them, 10, is the GCF.
How to use this GCF calculator
- Type two or more whole numbers, such as 84, 126, 210. You can enter up to 10.
- The answer updates as you type. You can also press Find the GCF.
- Read the GCF, then open the panels below it to see the work by Euclid’s algorithm, prime factorization or listing factors.
- Press Copy result to paste the answer and steps into your notes.
What your results mean
- GCF: the largest number that divides every number you entered.
- LCM (least common multiple): the smallest number that every number you entered divides into.
- Common factors: every number that divides all of your numbers. They are exactly the factors of the GCF.
- Each number ÷ GCF: what is left after you take out the GCF. These numbers share no factor except 1.
Method 1: List the factors
Write every factor of each number, circle the ones they all share, and pick the biggest. This works best for small numbers.
Example: find the GCF of 16 and 40.
- Factors of 16: 1, 2, 4, 8, 16
- Factors of 40: 1, 2, 4, 5, 8, 10, 20, 40
- Common factors: 1, 2, 4, 8
The biggest common factor is 8, so the GCF of 16 and 40 is 8.
Tip: list the factors of the smallest number first. The GCF must be one of them, so you only need to test those against the other numbers. To list factors quickly, use the factors calculator.
Method 2: Prime factorization
Break each number into primes. Keep only the primes that every number has, each with its smallest power, and multiply them. The result is the GCF.
Steps
- Write the prime factorization of each number.
- Find the primes that appear in every number.
- For each shared prime, use the smallest power you see.
- Multiply those prime powers together.
Example: find the GCF of 84, 126 and 210.
| Prime | In 84 | In 126 | In 210 | Smallest power |
|---|---|---|---|---|
| 2 | 2² | 2¹ | 2¹ | 2¹ |
| 3 | 3¹ | 3² | 3¹ | 3¹ |
| 5 | none | none | 5¹ | not shared |
| 7 | 7¹ | 7¹ | 7¹ | 7¹ |
Multiply the smallest powers: 2 × 3 × 7 = 42. So the GCF of 84, 126 and 210 is 42. 5 is left out because 84 and 126 do not have it.
If you use the largest power of every prime instead, you get the LCM, not the GCF. Mixing these up is the most common mistake with this method.
Method 3: Euclid’s algorithm
Divide the bigger number by the smaller one and keep the remainder. Then divide the smaller number by that remainder. Repeat until the remainder is 0. The last number you divided by is the GCF.
Example: find the GCF of 252 and 198.
- 252 = 198 × 1 + 54
- 198 = 54 × 3 + 36
- 54 = 36 × 1 + 18
- 36 = 18 × 2 + 0
The remainder is now 0, and the last number you divided by was 18. So the GCF of 252 and 198 is 18.
Why it works
Any number that divides both 252 and 198 also divides their difference, and so it divides the remainder 54. That means 252 and 198 have exactly the same common factors as 198 and 54. Each step swaps the pair for a smaller pair with the same GCF, until one number divides the other.
This idea is more than 2,000 years old. It appears in Book VII of Euclid’s Elements, and computers still use it because it needs only a few steps, even for huge numbers.
Three or more numbers
Find the GCF of the first two numbers, then the GCF of that answer and the next number, and so on. For 84, 126 and 210:
- GCF(84, 126): 126 = 84 × 1 + 42, then 84 = 42 × 2 + 0, so 42.
- GCF(42, 210): 210 = 42 × 5 + 0, so 42.
The GCF of all three is 42, the same answer as the prime method.
Which method should you use?
Use listing for small numbers, prime factorization when you also need the LCM, and Euclid’s algorithm for big numbers.
| Method | Best for | Watch out for |
|---|---|---|
| Listing factors | Numbers under about 100 | Missing a factor. Check that each factor has a partner. |
| Prime factorization | Getting the GCF and LCM together; three or more numbers | Using the largest power instead of the smallest |
| Euclid’s algorithm | Large numbers, like 6 digits or more | Stopping before the remainder is 0 |
How the GCF and LCM are connected
For two whole numbers, the GCF times the LCM equals the two numbers multiplied together: GCF × LCM = a × b.
Check it with 252 and 198. Their GCF is 18 and their LCM is 2,772. 18 × 2,772 = 49,896, and 252 × 198 = 49,896 too.
This gives a fast way to get the LCM of two numbers: LCM = a × b ÷ GCF. For 252 and 198, that is 49,896 ÷ 18 = 2,772.
Careful: this shortcut only works for two numbers. For 2, 4 and 6, the GCF is 2 and the LCM is 12. 2 × 12 = 24, but 2 × 4 × 6 = 48. For three or more numbers, find the LCM one pair at a time or use prime factors with the largest powers.
The calculator above shows the LCM next to the GCF. For the LCM on its own, use the LCM calculator.
Where the GCF is used
You use the GCF whenever you need to split things into the largest possible equal parts with nothing left over.
Simplifying fractions
Divide the top and bottom of a fraction by their GCF to simplify the fraction in one step. The GCF of 84 and 126 is 42, so 84/126 = (84 ÷ 42)/(126 ÷ 42) = 2/3. Because you divided by the greatest common factor, the answer is already in lowest terms.
Making equal groups
You have 84 red, 126 blue and 210 white beads. You want to make identical craft kits and use every bead. The GCF of 84, 126 and 210 is 42, so you can make at most 42 kits. Each kit gets 2 red, 3 blue and 5 white beads.
Tiling a floor
A floor is 252 cm long and 198 cm wide. You want the largest square tiles that fit with no cutting. The GCF of 252 and 198 is 18, so use 18 cm tiles. You need 14 tiles along the length and 11 across, which is 154 tiles.
Special cases: 1, zero and negative numbers
When the GCF is 1
If the only common factor is 1, the numbers are called coprime or relatively prime. 8 and 15 are coprime even though neither one is prime: 8 = 2³ and 15 = 3 × 5 share no prime. Two numbers in a row, like 20 and 21, are always coprime.
When one number is 0
Every number divides 0, so 0 does not limit the GCF. The GCF of 0 and 18 is 18. The GCF of a list where every number is 0 is not defined in school math, because there is no greatest number that divides 0. The calculator tells you if you enter only zeros. The LCM shown by this calculator is 0 when any number is 0. The separate LCM Calculator rejects 0: it finds the smallest positive common multiple, and 0 has none.
Negative numbers
The GCF is always given as a positive number. Use the size of each number and ignore the minus sign. The GCF of −24 and 36 is 12, the same as for 24 and 36.
GCF of algebra terms
To find the GCF of terms like 8a³b and 12a²b⁴, take the GCF of the numbers, then each shared letter with its smallest power.
The GCF of 8 and 12 is 4. Both terms have a, and the smallest power is a². Both have b, and the smallest power is b. So the GCF is 4a²b.
This calculator works with whole numbers only. To factor full expressions, use the polynomial factoring calculator.
GCF table for common pairs
Here are the GCF and LCM of 14 pairs you might meet in homework. Press a pair to see the steps in the calculator.
| Numbers | GCF | LCM | Simplified fraction |
|---|---|---|---|
| 4 | 24 | 8/12 = 2/3 | |
| 6 | 36 | 12/18 = 2/3 | |
| 5 | 75 | 15/25 = 3/5 | |
| 9 | 54 | 18/27 = 2/3 | |
| 7 | 70 | 14/35 = 2/5 | |
| 4 | 160 | 20/32 = 5/8 | |
| 12 | 72 | 24/36 = 2/3 | |
| 12 | 144 | 36/48 = 3/4 | |
| 15 | 180 | 45/60 = 3/4 | |
| 8 | 504 | 56/72 = 7/9 | |
| 30 | 180 | 60/90 = 2/3 | |
| 32 | 192 | 64/96 = 2/3 | |
| 50 | 300 | 100/150 = 2/3 | |
| 1 | 252 | 9/28 (already lowest terms) |
Common mistakes to avoid
- Mixing up the GCF and LCM. Leaving out 0, the GCF is never bigger than your smallest number, and the LCM is never smaller than your largest one.
- Taking the largest prime powers. That gives the LCM. The GCF uses the smallest.
- Counting 1 as a prime. Write 15 = 3 × 5, not 1 × 3 × 5.
- Keeping a prime that is not in every number. In 84, 126 and 210, the 5 only appears in 210, so it is not part of the GCF.
- Stopping Euclid’s algorithm too early. Keep going until the remainder is exactly 0.
- Giving a remainder as the answer. The GCF is the last number you divided by, not the last remainder.
Frequently asked questions
Can the GCF be bigger than the smallest number?
No. The GCF divides every number, so it can never be larger than the smallest number that is not 0. It equals the smallest number when that number divides all the others. For example, the GCF of 12 and 48 is 12.
What is the GCF of two prime numbers?
It is 1 when the primes are different, because a prime has no factors except 1 and itself. The GCF of 7 and 13 is 1. The GCF of a prime and the same prime is that prime.
How do I find the GCF in Excel or Google Sheets?
Use the GCD function. Typing =GCD(84, 126, 210) returns 42 in both programs. Excel shows a #NUM! error for negative numbers, so wrap them in ABS(), like =GCD(ABS(-24), 36).
How many numbers can I enter?
From 2 to 10 numbers at a time. Each one can be as large as 1,000,000,000,000 (one trillion), positive or negative.
Can I find the GCF of decimals or fractions?
The GCF is defined for whole numbers. Some lessons handle decimals by scaling them first: 1.2 and 1.8 become 12 and 18, whose GCF is 6, so the answer is 0.6. Check how your teacher wants it done.
Are my numbers saved or sent anywhere?
No. The calculator runs in your browser and nothing you type is sent to us. Your numbers only go into the page link if you press Copy link.
Related calculators
How this calculator works
The calculator finds the GCF with Euclid’s algorithm, one pair at a time, and shows each division. It finds the prime factorization of each number by dividing out primes, then keeps the smallest power of each shared prime. The LCM is worked out from the GCF using exact whole-number math, so very large results do not get rounded. Everything runs in your browser.
Limit: 2 to 10 whole numbers, each up to 1,000,000,000,000 in size. Sources for the rules used on this page:
- Euclid’s Elements, Book VII, Proposition 2 (D. E. Joyce, Clark University) (opens in a new tab)
- Wolfram MathWorld: Greatest Common Divisor (opens in a new tab)
- Microsoft Support: GCD function in Excel (opens in a new tab)
- Google Docs Editors Help: GCD function in Sheets (opens in a new tab)
Last updated .
