Algebra
GCF Calculator: Find The Greatest Common Factor Step By Step
Last updated: October 2026
A GCF calculator finds the greatest common factor: the largest whole number that divides evenly into every number in a set. The GCF of 12 and 18 is 6, and the GCF of 30 and 54 is also 6. You can find it by listing factors, using prime factors, the ladder method or the Euclidean algorithm.
- Free, no sign-up
- Shows the working
- Runs on your device
The greatest common factor is one of the most useful tools in arithmetic and algebra. It simplifies fractions, splits things into equal groups and is the first step in factoring polynomials. This guide covers five ways to find it, then shows each of those uses with worked examples. Every number and expression was checked with Python and the SymPy algebra library.
Note: Calc Solver (calc-solver.co) is an independent guide site and is not affiliated with any calculator mentioned here.
What The Greatest Common Factor Is
The greatest common factor (GCF) of two or more numbers is the largest whole number that divides into all of them with no remainder. A factor is a number that divides evenly into another, a common factor is shared by every number in the set, and the GCF is the biggest of those.
Take 12 and 18:
- Factors of 12: 1, 2, 3, 4, 6, 12
- Factors of 18: 1, 2, 3, 6, 9, 18
The common factors are 1, 2, 3 and 6. The largest is 6, so GCF(12, 18) = 6.
The GCF goes by several names, and they all mean the same thing:
| Name | Where you see it |
|---|---|
| Greatest common factor (GCF) | Most U.S. math classes |
| Greatest common divisor (GCD) | Higher math, programming, Excel and calculators |
| Highest common factor (HCF) | The UK, India and many other countries |
| Greatest common measure (GCM) | Older textbooks |
You may also see "greatest common denominator." That name is a mix-up. Denominators matter for the least common denominator when adding fractions, which comes from the LCM, not the GCF.
How To Use The GCF Calculator
The GCF calculator above handles whole numbers, fractions and algebra terms. It takes three steps:
- Pick a tab. Use "GCF of Numbers" for a list of whole numbers, "Simplify a Fraction" to reduce a fraction, or "GCF With Variables" for terms like 12x³y².
- Type your input. Separate numbers with commas or spaces, like 36, 60, 84. You can enter up to 15 numbers.
- Choose a method. Pick the method your class uses so the steps match your homework.
Each result ends with a check. Dividing every number by the GCF should leave numbers that share no other factor. For 30 and 54, dividing by 6 gives 5 and 9, which have no common factor except 1, so 6 is correct.
Five Ways To Find The GCF By Hand
All five methods give the same answer. Listing factors is easiest for small numbers. Prime factorization and the ladder show the most structure. The Euclidean algorithm is the fastest for large numbers, and the binary method is how many computers do it.
Method 1: List The Factors
Write every factor of each number, then circle the largest one they share. For 30 and 54:
- Factors of 30: 1, 2, 3, 5, 6, 10, 15, 30
- Factors of 54: 1, 2, 3, 6, 9, 18, 27, 54
GCF(30, 54) = 6.
To list factors without missing any, test divisors from 1 up to the square root and write each pair as you go. For 54, the pairs are 1 × 54, 2 × 27, 3 × 18 and 6 × 9. Our factor calculator lists every factor pair for you. This method gets slow past two or three digits.
Method 2: Use Prime Factorization
Break each number into primes. Then multiply only the primes that every number shares, using the lowest power that appears.
For 48 and 180:
| Number | Prime factorization | Power of 2 | Power of 3 | Power of 5 |
|---|---|---|---|---|
| 48 | 2⁴ × 3 | 2⁴ | 3¹ | none |
| 180 | 2² × 3² × 5 | 2² | 3² | 5¹ |
| Lowest shared power | 2² | 3¹ | not shared |
GCF = 2² × 3 = 12.
A Venn diagram shows the same idea. Put the shared primes (2, 2, 3) in the overlap and the leftover primes in each circle. The product of the overlap is the GCF. The 5 sits only in 180's circle, so it is not part of the GCF.
Method 3: The Ladder (Upside-Down Division)
Write the numbers in a row and divide all of them by a prime that goes into every one. Repeat until no prime divides all of them. The GCF is the product of the primes down the left side.
For 36, 60 and 84:
| Divide by | 36 | 60 | 84 |
|---|---|---|---|
| 2 | 18 | 30 | 42 |
| 2 | 9 | 15 | 21 |
| 3 | 3 | 5 | 7 |
No prime divides 3, 5 and 7, so stop. GCF = 2 × 2 × 3 = 12.
Notice the rule is stricter than the LCM ladder. For the GCF, a prime must divide every number in the row, not just two of them.
Method 4: The Euclidean Algorithm
The Euclidean algorithm finds the GCF by repeated division. Divide the larger number by the smaller, replace the larger with the remainder, and repeat. When the remainder hits 0, the last divisor is the GCF.
For 1071 and 462:
| Step | Division | Remainder |
|---|---|---|
| 1 | 1071 = 2 × 462 + 147 | 147 |
| 2 | 462 = 3 × 147 + 21 | 21 |
| 3 | 147 = 7 × 21 + 0 | 0 |
The last nonzero remainder is 21, so GCF(1071, 462) = 21. That took three divisions, with no factoring at all.
It works because any number that divides both 1071 and 462 must also divide the remainder 147. So GCF(1071, 462) = GCF(462, 147) = GCF(147, 21) = 21. Each step keeps the GCF the same while the numbers shrink.
This method is more than 2,000 years old. It appears in Book 7 of Euclid's Elements, written around 300 BC, as described in the history of the Euclidean algorithm.
Method 5: The Binary GCD Method
The binary GCD method, also called Stein's algorithm, uses only halving and subtraction. Computers like it because halving a binary number is very fast. The NIST Dictionary of Algorithms credits it to J. Stein in 1967.
The rules are:
- If both numbers are even, halve both and remember a factor of 2.
- If only one is even, halve that one.
- If both are odd, replace the larger with the difference.
- Stop when the numbers are equal. Multiply by any saved 2s.
For 48 and 18: both even, so save a 2 and use 24 and 9. Halve 24 three times to get 3 and 9. Both odd: 9 − 3 = 6, giving 3 and 6. Halve 6 to get 3 and 3. They match, so the result is 3 × 2 = 6.
You will rarely do this by hand, but it explains why a computer can find the GCF of two huge numbers almost instantly.
Which Method Should You Use?
Pick the method that fits the size of your numbers and what your teacher wants to see.
| Method | Best for | Watch out for |
|---|---|---|
| List factors | Numbers under 100 | Missing a factor pair |
| Prime factorization | Showing structure, finding the LCM at the same time | Using the highest power instead of the lowest |
| Ladder | Three or more numbers at once | Dividing by a prime that misses one number |
| Euclidean algorithm | Large numbers, mental math with two numbers | Mixing up the divisor and the remainder |
| Binary GCD | Computer code | It is slow to write out by hand |
Finding The GCF Of Three Or More Numbers
To find the GCF of three or more numbers, use the ladder or prime factors, or work in pairs. The pair method finds the GCF of the first two numbers, then the GCF of that result with the next number.
For 18, 27 and 45:
- GCF(18, 27) = 9
- GCF(9, 45) = 9
So GCF(18, 27, 45) = 9.
A shortcut: the GCF can never be larger than the smallest number in the list. Start by testing whether the smallest number divides all the others. For 14 and 42, 14 divides 42 exactly, so GCF(14, 42) = 14 right away.
Coprime Numbers: When The GCF Is 1
Two numbers are coprime, or relatively prime, when their GCF is 1. They share no factor except 1, even though neither has to be prime. For example, 8 = 2³ and 15 = 3 × 5 have no common prime, so GCF(8, 15) = 1.
Some pairs are always coprime:
- Consecutive whole numbers, like 20 and 21. Any factor of both would also divide their difference, which is 1.
- Two different primes, like 7 and 11.
- 1 and any number.
The Euclidean algorithm takes the most steps on pairs of consecutive Fibonacci numbers, as G. Lamé proved in 1845. For 89 and 55, it takes 9 divisions to reach a GCF of 1. That is a handy pair for testing a GCF program.
GCF Rules For Zero, Negatives And Special Cases
A few kinds of input follow fixed rules, and knowing them saves you a calculation.
| Case | Rule | Example |
|---|---|---|
| One number divides the other | GCF is the smaller number | GCF(14, 42) = 14 |
| Two different primes | GCF is 1 | GCF(13, 17) = 1 |
| One number is 0 | GCF is the other number | GCF(0, 9) = 9 |
| Both numbers are 0 | Undefined | GCF(0, 0) has no answer |
| Negative numbers | Use absolute values | GCF(−24, 36) = 12 |
| A number and itself | GCF is that number | GCF(25, 25) = 25 |
The zero rule surprises people. Every number divides 0 evenly, so the largest number that divides both 0 and 9 is 9 itself.
How The GCF And LCM Work Together
The GCF and the least common multiple (LCM) are two sides of the same prime factorization. The GCF uses shared primes at their lowest power. The LCM uses every prime at its highest power.
For two numbers, they are linked by a simple rule: GCF × LCM = a × b. For 12 and 18, the GCF is 6 and the LCM is 36, and 6 × 36 = 216 = 12 × 18. So once you know the GCF, LCM = (a × b) ÷ GCF.
This rule only works for two numbers. For three or more, find each one separately. The LCM calculator covers the least common multiple in full, including word problems and the least common denominator.
Simplifying Fractions With The GCF
The fastest way to reduce a fraction to lowest terms is to divide the top and bottom by their GCF in one step. You get the simplest form right away, with no repeated halving.
Simplify 84/126:
- GCF(84, 126) = 42.
- 84 ÷ 42 = 2 and 126 ÷ 42 = 3.
- 84/126 = 2/3.
Dividing by a smaller common factor still works, but takes more steps. Dividing by 2 gives 42/63, then by 3 gives 14/21, then by 7 gives 2/3. The GCF gets there in one move.
A fraction is in simplest form when the GCF of the top and bottom is 1. For 48/180, the GCF is 12, so it reduces to 4/15. Since GCF(4, 15) = 1, you are done. For mixed numbers and operations with fractions, the fraction calculator shows every step.
GCF Word Problems
GCF word problems ask for the largest equal group, size or amount that splits several things with nothing left over. Look for phrases like "greatest number of groups," "largest size," "split evenly" or "no leftovers."
Making identical kits. A teacher has 56 pencils and 72 erasers. What is the greatest number of identical kits she can make using all of them? GCF(56, 72) = 8. She can make 8 kits, each with 7 pencils and 9 erasers.
Cutting equal pieces. Three ribbons are 18, 27 and 45 inches long. You want to cut them into pieces of the same length, as long as possible, with no waste. GCF(18, 27, 45) = 9, so each piece is 9 inches. You get 2 + 3 + 5 = 10 pieces.
Tiling with squares. A garden bed is 24 feet by 40 feet. What is the largest square plot size that fills it exactly? GCF(24, 40) = 8, so each plot is 8 feet by 8 feet. That gives 3 rows of 5, or 15 plots.
If a problem asks when things happen together again, or for the smallest amount that works, it needs the LCM instead.
Finding The GCF With Variables
To find the GCF of algebra terms (monomials), find the GCF of the numbers, then take each variable that appears in every term at its lowest power.
For 12x³y² and 18x²y⁵:
- Numbers: GCF(12, 18) = 6.
- x: both terms have x. The lowest power is x².
- y: both terms have y. The lowest power is y².
- GCF = 6x²y².
For three terms, 15a²b, 25ab³ and 35a³b²:
- Numbers: GCF(15, 25, 35) = 5.
- a: the lowest power is a¹.
- b: the lowest power is b¹.
- GCF = 5ab.
If a variable is missing from even one term, it is not part of the GCF. The GCF of 4x²y and 6x³ is 2x², because the second term has no y.
Factoring Out The GCF From A Polynomial
Factoring out the GCF means writing a polynomial as the GCF times a simpler expression. It is always the first step in factoring, and skipping it is one of the most common reasons an answer gets marked incomplete.
Factor 8x⁴ + 12x³ − 20x²:
- GCF of 8, 12 and 20 is 4.
- The lowest power of x is x².
- The GCF is 4x². Divide each term: 8x⁴ ÷ 4x² = 2x², 12x³ ÷ 4x² = 3x and −20x² ÷ 4x² = −5.
- Answer: 4x²(2x² + 3x − 5).
The part in parentheses may factor further. Here, 2x² + 3x − 5 = (2x + 5)(x − 1), so the full answer is 4x²(2x + 5)(x − 1). For trinomials, the factor calculator on this site shows the next steps.
Negative GCF. When the first term is negative, many teachers want you to factor out a negative GCF so the first term inside is positive: −6x² + 9x = −3x(2x − 3). Notice that the sign of every term inside changes.
Binomial GCF. The GCF can be a whole expression. In 3x(x + 2) + 5(x + 2), both terms share (x + 2), so the answer is (x + 2)(3x + 5). This step is the heart of factoring by grouping.
The GCF Of Fractions And Decimals
The GCF is defined for whole numbers, but you can extend it to fractions and decimals with one extra step.
Fractions: GCF of fractions = GCF of the numerators ÷ LCM of the denominators. For 2/3 and 4/9, that is GCF(2, 4) ÷ LCM(3, 9) = 2 ÷ 9 = 2/9. Check: 2/3 ÷ 2/9 = 3 and 4/9 ÷ 2/9 = 2. Both are whole numbers, so 2/9 divides both exactly.
Decimals: multiply every number by the same power of 10 to make them whole, find the GCF, then divide back. For 1.2 and 1.8, multiply by 10 to get 12 and 18. GCF(12, 18) = 6, and 6 ÷ 10 = 0.6. Check: 1.2 ÷ 0.6 = 2 and 1.8 ÷ 0.6 = 3.
Properties Of The GCF
A few properties of the GCF explain why the methods above work, and they help on proofs and harder problems.
| Property | Rule | Example |
|---|---|---|
| Order does not matter | GCF(a, b) = GCF(b, a) | GCF(12, 18) = GCF(18, 12) = 6 |
| Grouping does not matter | GCF(a, b, c) = GCF(GCF(a, b), c) | GCF(18, 27, 45) = GCF(9, 45) = 9 |
| Subtracting keeps the GCF | GCF(a, b) = GCF(a − b, b) | GCF(48, 18) = GCF(30, 18) = 6 |
| Scaling scales the GCF | GCF(ka, kb) = k × GCF(a, b) | GCF(60, 90) = 10 × GCF(6, 9) = 30 |
| GCF times LCM | GCF(a, b) × LCM(a, b) = a × b | 6 × 36 = 12 × 18 |
One more property comes up in algebra 2 and number theory, called Bézout's identity. The GCF of a and b can always be written as ax + by for some whole numbers x and y. Working the Euclidean steps for 1071 and 462 backward gives 21 = 7 × 462 − 3 × 1071. This backward version, called the extended Euclidean algorithm, is how computers find the inverse numbers used in encryption.
Finding The GCF On A Calculator, In Excel Or In Code
Many tools call the GCF "gcd," short for greatest common divisor. Here is where to find it.
TI-84 Plus CE: press MATH, move right to NUM and choose 9: gcd(. Type two numbers separated by a comma, close the parenthesis and press ENTER. It takes two numbers at a time, so nest it for three: gcd(gcd(18,27),45).
Casio fx-991CW ClassWiz: choose GCD from the Numeric Calc menu, type the numbers separated by a comma, and press equals. The older fx-991EX does not have a GCD function.
Excel and Google Sheets: type =GCD(24, 36) to get 12. According to Microsoft's GCD function page, Excel accepts up to 255 numbers, drops the decimal part of any non-whole number, and returns a #NUM! error for negative numbers.
Python: math.gcd(24, 36) returns 12. Since Python 3.9, it accepts more than two numbers, like math.gcd(36, 60, 84).
JavaScript has no built-in GCD, so students often write the Euclidean algorithm as a short loop:
function gcd(a, b) {
a = Math.abs(a); b = Math.abs(b);
while (b) { [a, b] = [b, a % b]; }
return a;
}
gcd(1071, 462); // 21
Common GCF Mistakes
Most GCF errors come from mixing it up with the LCM or choosing the wrong prime powers.
| Mistake | Example | Fix |
|---|---|---|
| Giving the LCM instead | GCF(12, 18) = 36 | The GCF can never be bigger than 12. It is 6 |
| Stopping at any common factor | GCF(24, 32) = 4 | 8 also divides both. GCF = 8 |
| Using the highest prime power | 2⁴ × 3² for 48 and 180 | Use the lowest shared powers: 2² × 3 = 12 |
| Including a prime that is not shared | Adding the 5 from 180 | Only primes in every number count |
| Dividing a ladder row by a prime that misses one number | Dividing 3, 5, 7 by 3 | Stop when no prime divides all of them |
| Taking a variable missing from one term | GCF(4x²y, 6x³) = 2x²y | The second term has no y: GCF = 2x² |
| Forgetting to flip signs with a negative GCF | −6x² + 9x = −3x(2x + 3) | Every sign inside changes: −3x(2x − 3) |
Summary
- The GCF is the largest whole number that divides evenly into every number in a set. It is also called the GCD or HCF.
- List factors for small numbers, use prime factors (lowest shared powers) or the ladder for several numbers, and use the Euclidean algorithm for big ones.
- Coprime numbers have a GCF of 1. Zero and negatives follow simple fixed rules.
- Divide the top and bottom of a fraction by their GCF to reach lowest terms in one step.
- For algebra terms, take the GCF of the numbers and the lowest power of each shared variable, then factor it out first.
Next step: enter your numbers, fraction or algebra terms in the GCF calculator at the top of this page. For other number tools, try the math solver.
Frequently Asked Questions
What is the GCF of 30 and 54?
The GCF of 30 and 54 is 6. In primes, 30 = 2 × 3 × 5 and 54 = 2 × 3³. They share one 2 and one 3, so the GCF is 2 × 3 = 6. With the Euclidean algorithm, 54 = 1 × 30 + 24, then 30 = 1 × 24 + 6, then 24 = 4 × 6 + 0. The last divisor is 6.
What is the GCF of 24 and 32?
The GCF of 24 and 32 is 8. The factors of 24 are 1, 2, 3, 4, 6, 8, 12 and 24. The factors of 32 are 1, 2, 4, 8, 16 and 32. The largest one they share is 8. In primes, 24 = 2³ × 3 and 32 = 2⁵, and the lowest shared power is 2³ = 8.
Is 2 the GCF of 14 and 42?
No. 2 is a common factor of 14 and 42, but not the greatest one. Since 42 ÷ 14 = 3 exactly, 14 divides both numbers, so GCF(14, 42) = 14. Whenever the smaller number divides the larger one evenly, the smaller number is the GCF. Checking that first saves a lot of work.
Can the GCF be larger than the numbers?
No. The GCF has to divide every number in the set, so it can never be larger than the smallest one. It equals the smallest number only when that number divides all the others, like GCF(6, 18, 30) = 6. If your answer is bigger than your smallest number, you most likely found a common multiple instead.
What is the GCF of two prime numbers?
The GCF of two different prime numbers is always 1. A prime has only two factors, 1 and itself, so two different primes share only 1. For example, GCF(13, 17) = 1. If the two primes are the same number, like 7 and 7, the GCF is that prime. Two different primes are always coprime.
Where is the GCF used outside of math class?
The GCF shows up whenever something needs to be split or scaled evenly. Screen aspect ratios are one example: a 1920 by 1080 display has a GCF of 120, and dividing both by 120 gives the familiar 16:9 ratio. The GCF also helps with recipe scaling, packing equal boxes, cutting materials with no waste and cryptography.
Try it with your own numbers
Use a free CalcSolver tool to check the examples in this guide.