GCF Calculator

This GCF calculator finds the greatest common factor of two or more whole numbers and shows the prime factorization of each one, the Euclidean algorithm steps and the LCM.

GCF Calculator inputs

Enter 2 to 20 positive whole numbers separated by commas, spaces or new lines.

Result

Enter your values to see the result.

  • Formula v1.0, unit-tested
  • Examples generated by the calculator
  • Updated
  • How we calculate
On this page

Formula

GCF(a, b) = GCF(b, a mod b), repeated until the remainder is 0

a, b
the whole numbers being compared (a ≥ b)
a mod b
the remainder when a is divided by b
GCF
the largest whole number that divides every input with no remainder

What the greatest common factor is

The greatest common factor (GCF) of a set of whole numbers is the largest number that divides every one of them with no remainder. The factors of 18 are 1, 2, 3, 6, 9 and 18, and the factors of 24 are 1, 2, 3, 4, 6, 8, 12 and 24. They share 1, 2, 3 and 6, so the GCF is 6. You’ll also see it called the greatest common divisor (GCD) or the highest common factor (HCF). All three names mean the same thing.

How to use the GCF calculator

  1. Type two or more whole numbers into the box, separated by commas, spaces or new lines, such as 36, 60, 96.
  2. The GCF appears as you type. A note tells you if the numbers are coprime (GCF of 1).
  3. Below the answer you’ll see the least common multiple, the prime factorization of the GCF, and how many times the GCF goes into each number. That last figure is handy when you split items into equal groups.
  4. The working shows each number’s prime factorization and, for two numbers, every step of the Euclidean algorithm.

Three ways to find the GCF by hand

Listing factors

Write out every factor of each number and pick the largest one they share. This works well for small numbers. For 16 and 40, the factors of 16 are 1, 2, 4, 8 and 16, and 8 is the largest that also divides 40.

Prime factorization

Break each number into primes, then multiply the primes they have in common, using the lowest power of each.

  • 48 = 2⁴ × 3
  • 180 = 2² × 3² × 5

Both contain 2 and 3. The lowest power of 2 is 2² and the lowest power of 3 is 3¹, so the GCF is 2² × 3 = 12. The 5 doesn’t count because 48 doesn’t contain it. This is the method most teachers ask for, and it’s how the GCF calculator builds the factorization it shows.

The Euclidean algorithm

For large numbers, factoring is slow. The Euclidean algorithm uses only division with remainder. Divide the larger number by the smaller, then replace the pair with the smaller number and the remainder, and repeat until the remainder is 0:

  • 180 = 3 × 48 + 36
  • 48 = 1 × 36 + 12
  • 36 = 3 × 12 + 0

The last non-zero remainder, 12, is the GCF. The method goes back to Euclid’s Elements, written around 300 BC, and computers still use it because it takes only a handful of steps even for numbers with many digits.

GCF reference table

Numbers GCF LCM
12 and 18 6 36
14 and 21 7 42
15 and 25 5 75
24 and 36 12 72
30 and 45 15 90
48 and 64 16 192
54 and 72 18 216
60 and 84 12 420
75 and 100 25 300

Notice that GCF × LCM equals the product of the two numbers in every row. For 12 and 18, 6 × 36 = 216 = 12 × 18.

Where the GCF is used

Simplifying fractions

Dividing the numerator and denominator by their GCF reduces a fraction to lowest terms in one step. For 90/150, the GCF is 30, so 90/150 = 3/5. The fraction calculator simplifies every answer this way.

Splitting things into equal groups

A teacher with 32 pencils and 48 erasers wants identical kits with nothing left over. The GCF of 32 and 48 is 16, so she can make 16 kits, each with 2 pencils and 3 erasers.

Tiling and cutting

To cut a 60 cm × 84 cm board into the largest identical squares with no waste, use squares with sides of GCF(60, 84) = 12 cm. That gives 5 × 7 = 35 squares.

Ratios and factoring

Reducing a ratio such as 45 : 60 to 3 : 4 means dividing both parts by their GCF of 15. The ratio calculator does this. In algebra, factoring out the GCF is the first step in factoring expressions: 12x + 18 = 6(2x + 3).

Common mistakes

  • Taking the highest powers. The highest power of each prime gives the LCM, not the GCF. For the GCF, take the lowest power of the primes that every number shares.
  • Including primes that aren’t shared. A prime must appear in every number to be part of the GCF.
  • Stopping the Euclidean algorithm early. Keep dividing until the remainder is 0. The GCF is the divisor in that last step, not the final remainder of 0.
  • Assuming coprime numbers must be prime. 8 and 15 are both composite, yet their GCF is 1.

Glossary

  • Factor: a whole number that divides another with no remainder.
  • Prime number: a number greater than 1 whose only factors are 1 and itself.
  • Coprime (relatively prime): numbers whose GCF is 1.
  • Least common multiple (LCM): the smallest number that every number in the set divides into.

Worked examples

GCF of two numbers

Find the largest number that divides both 84 and 126.

Inputs: Whole numbers = 84, 126

84 = 2² × 3 × 7 126 = 2 × 3² × 7 Common prime factors (lowest power of each): 2 × 3 × 7 = 42 Euclid: 126 = 1 × 84 + 42 Euclid: 84 = 2 × 42 + 0

Answer: The greatest common factor of 84, 126 is 42.

Equal-size gift bags from three supplies

You have 120 pencils, 168 erasers and 216 stickers and want identical bags with nothing left over.

Inputs: Whole numbers = 120, 168, 216

120 = 2³ × 3 × 5 168 = 2³ × 3 × 7 216 = 2³ × 3³ Common prime factors (lowest power of each): 2³ × 3 = 24

Answer: The greatest common factor of 120, 168, 216 is 24.

Numbers with no common factor

Edge case: 35 and 64 share no prime factor, so they are coprime.

Inputs: Whole numbers = 35, 64

35 = 5 × 7 64 = 2⁶ The numbers share no prime factor, so the GCF is 1. Euclid: 64 = 1 × 35 + 29 Euclid: 35 = 1 × 29 + 6 Euclid: 29 = 4 × 6 + 5 Euclid: 6 = 1 × 5 + 1 Euclid: 5 = 5 × 1 + 0

Answer: The greatest common factor of 35, 64 is 1.

Assumptions and limitations

  • Enter 2 to 20 positive whole numbers, each from 1 to 1,000,000,000,000. Decimals, fractions, 0 and negative numbers aren't accepted.
  • Separate numbers with commas, spaces or new lines, and don't use thousands separators inside a number.
  • Arithmetic uses exact big-integer math, so results never lose precision.
  • The GCF of more than two numbers is found by applying the Euclidean algorithm to the list one number at a time. The Euclidean steps are shown when you enter exactly two numbers.
  • Prime factorizations use trial division. The GCF's own factorization takes the lowest power of each prime the numbers share.
  • GCF, GCD (greatest common divisor) and HCF (highest common factor) are three names for the same number.

Frequently asked questions

How do you calculate the GCF of two numbers?

List the prime factors of each number and multiply the primes they share, using the lowest power of each. For 60 = 2² × 3 × 5 and 90 = 2 × 3² × 5, the shared primes are 2, 3 and 5, so the GCF is 2 × 3 × 5 = 30.

How do you calculate the GCF of 3 numbers?

Find the GCF of the first two, then the GCF of that result and the third number. For 18, 30 and 42, GCF(18, 30) = 6 and GCF(6, 42) = 6. The calculator accepts up to 20 numbers and does this for you.

How do you calculate the GCF using prime factorization?

Break each number into primes, for example with a factor tree, then circle the primes that appear in every factorization. Multiply them, taking each prime to the smallest exponent it has in any of the numbers. The calculator lists every factorization so you can check your tree.

What is the difference between the GCF and the LCM?

The GCF is the largest number that divides all of the numbers, so it can't be bigger than the smallest one. The LCM is the smallest number that all of them divide into, so it can't be smaller than the largest. For two numbers, GCF × LCM = a × b. The [LCM calculator](/lcm-calculator/) works out multiples in detail.

What does a GCF of 1 mean?

The numbers share no prime factor, so they're called relatively prime or coprime. 35 and 64 are coprime even though neither is prime. A fraction whose numerator and denominator are coprime is already in lowest terms.

How do I find the GCF on a calculator?

Most basic calculators have no GCF key. Some graphing calculators have a gcd( function in the math or number menu. You can also use repeated division: divide the larger number by the smaller, keep the remainder, and repeat until the remainder is 0. The last non-zero remainder is the GCF.

Can the GCF be one of the numbers?

Yes. If the smallest number divides all the others, it's the GCF. For 12, 36 and 60, the GCF is 12.

Sources

  1. 2.5 Prime Factorization and the Least Common Multiple — Prealgebra 2e — OpenStax, Rice University. Checked October 10, 2026.
  2. Greatest Common Divisor — Wolfram MathWorld. Checked October 10, 2026.
  3. Euclidean Algorithm — Wolfram MathWorld. Checked October 10, 2026.

LCM Calculator

Least common multiple of 2+ numbers, with prime factors and steps.

Math