GCF Calculator

Enter two or more whole numbers to find the largest number that divides all of them, with Euclid's algorithm written out and a second check using prime factors.

Your results

–

Save this calculation and come back to it any time. Members only — $5 every 3 months, ad-free.

Become a member

How to use the GCF calculator

  1. Type two or more whole numbers, separated by commas, spaces or new lines. You can enter up to 50.
  2. The greatest common factor appears at the top as you type.
  3. Read the steps of Euclid's algorithm underneath, then the prime factorization check.
  4. Use the last table to simplify a fraction or ratio: it divides each number by the GCF.

Negative numbers are allowed; the sign is ignored, because the GCF is always given as a positive number.

How the greatest common factor is calculated

The calculator uses Euclid's algorithm, which finds the GCF by repeated division instead of listing factors:

GCF(a, b) = GCF(b, a mod b), and GCF(a, 0) = a For a list: GCF(a, b, c) = GCF(GCF(a, b), c)

"a mod b" is the remainder when a is divided by b. Any number that divides both a and b also divides the remainder, so replacing the pair with the smaller number and the remainder keeps the same GCF. The numbers shrink quickly, and when the remainder hits 0, the last divisor is the answer. For a longer list, find the GCF of the first two, then the GCF of that result and the next number, and so on.

As a second check, the calculator factors each number into primes. The GCF is the product of the primes that appear in every number, each raised to the smallest power it appears with.

Worked example

The calculator starts with 24, 36 and 60.

  1. Start with 36 and 24: 36 = 1 × 24 + 12.
  2. Divide 24 by the remainder 12: 24 = 2 × 12 + 0. The remainder is 0, so GCF(36, 24) = 12.
  3. Bring in 60: 60 = 5 × 12 + 0, so GCF(12, 60) = 12.

Prime check: 24 = 2³ × 3, 36 = 2² × 3² and 60 = 2² × 3 × 5. The primes in all three are 2 (lowest power 2²) and 3 (lowest power 3¹), so the GCF is 2² × 3 = 12. Dividing each number by 12 gives the simplest ratio 2 : 3 : 5.

Euclid's algorithm vs. listing factors

Method How it works Best for
List the factors Write every factor of each number and pick the largest shared one Small numbers
Prime factorization Multiply the shared primes at their lowest powers Seeing why the answer is what it is
Euclid's algorithm Divide and keep the remainder until it reaches 0 Large numbers; it needs very few steps

Euclid's method stays fast even for big numbers. For 1,071 and 462 it takes three divisions: 1,071 = 2 × 462 + 147, then 462 = 3 × 147 + 21, then 147 = 7 × 21 + 0, so the GCF is 21. Listing the factors of numbers in the billions would take far longer.

Where the GCF is useful

The most common use is simplifying fractions: divide the top and bottom by their GCF. For 24/36 the GCF is 12, so the fraction reduces to 2/3 in one step. The GCF also tells you the largest equal groups you can split things into, such as cutting boards of 24, 36 and 60 inches into the longest equal pieces with no waste (12 inches). When the GCF is 1, the numbers are coprime: they share no factor other than 1. To list every shared factor, not just the greatest, use the common factor calculator.

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. GCD is common in the US and in programming, and HCF is the usual term in the UK.

What is the GCF of two prime numbers?

It is 1 if the primes are different, because a prime's only factors are 1 and itself. Two different primes, such as 17 and 31, are therefore always coprime.

What happens if one of the numbers is 0?

Every whole number divides 0, so GCF(a, 0) = a. The calculator handles a 0 in the list this way. If every number is 0, there is no greatest common factor, and the calculator asks for a nonzero number.

How are the GCF and the LCM related?

For two numbers, GCF × LCM = a × b. For 24 and 36: the GCF is 12 and the LCM is 72, and 12 × 72 = 864 = 24 × 36. The calculator shows the LCM too, and the LCM calculator explains it in full.

Related calculators

  • LCM Calculator — Least common multiple of two or more whole numbers, worked out by prime factorization and by the GCF method.
  • Common Factor Calculator — Every factor shared by two or more whole numbers, with the greatest common factor and each number's factor list.
  • Prime Factorization Calculator — Break a number into prime factors with exponents, see the factor tree, check if it is prime and count its divisors.
  • Fraction Calculator — Add, subtract, multiply and divide fractions and mixed numbers, simplify fractions and turn decimals into fractions.

Results are calculated in your browser. Double-check anything important before you rely on it. See our disclaimer.