Skip to content
PercentPoint

Greatest Common Factor (GCF) Calculator

Find the greatest common factor of two or more whole numbers, with the prime factorizations, the full list of common factors and the steps of Euclid’s algorithm, so you can show your work.

For planning only. Your school, syllabus or accountant has the final word. First published · Last reviewed by PercentPoint.

How to use the GCF calculator

  1. Type the numbers separated by commas or spaces, such as 54, 36 or 12 18 30. You can enter up to twenty whole numbers up to one trillion.
  2. Read the GCF. If the answer is 1, the numbers are relatively prime: they share no factor except 1.
  3. Use the working. The panel lists each number’s prime factorization, every common factor, and for two numbers the division steps of Euclid’s algorithm. The last line divides each number by the GCF, which is the simplified fraction or ratio.

The greatest common factor is also called the greatest common divisor (GCD) or highest common factor (HCF). They all mean the same thing: the largest whole number that divides each of your numbers with no remainder.

Method 1: prime factorization

Write each number as a product of primes, then multiply the primes they have in common, each to the lowest power that appears in every number.

54 = 2 × 3 × 3 × 3 = 2 × 3³
36 = 2 × 2 × 3 × 3 = 2² × 3²
shared: one 2 and two 3s → GCF = 2 × 3² = 18

This is the worked example that opens section 7.1 of the open textbook Elementary Algebra 2e from OpenStax: the GCF of 54 and 36 is 18. Prime factorizations themselves are taught in Prealgebra 2e section 2.5, with a factor tree or the “ladder” of repeated division: 48 = 2⁴ × 3, 84 = 2² × 3 × 7 and 120 = 2³ × 3 × 5.

The method extends to three or more numbers. For 12, 18 and 30: 12 = 2² × 3, 18 = 2 × 3², 30 = 2 × 3 × 5. The only primes in all three are one 2 and one 3, so the GCF is 6.

Method 2: Euclid’s algorithm

For large numbers, factoring is slow. Euclid’s algorithm needs only division. Divide the larger number by the smaller, then replace the pair with the smaller number and the remainder. Repeat until the remainder is 0. The last nonzero remainder is the GCF.

54 = 1 × 36 + 18
36 = 2 × 18 + 0 → GCF = 18

A longer case: for 1,071 and 462, 1071 = 2 × 462 + 147, then 462 = 3 × 147 + 21, then 147 = 7 × 21 + 0. The GCF is 21, found in three steps without factoring either number.

It works because any number that divides both a and b also divides the remainder a − q × b, so the pair (a, b) and the pair (b, remainder) have exactly the same common factors. The numbers shrink quickly, which is why computers use this method. For more than two numbers, find the GCF of the first two, then the GCF of that result and the third, and so on.

Method 3: list the factors

For small numbers, listing works well and is easy to check. The factors of 36 are 1, 2, 3, 4, 6, 9, 12, 18, 36. The factors of 54 are 1, 2, 3, 6, 9, 18, 27, 54. The common ones are 1, 2, 3, 6, 9 and 18, and the greatest is 18.

Listing is how most textbooks first introduce the idea, and it is a good way to check an answer from one of the faster methods. Notice that every common factor divides the GCF. The calculator’s “common factors” line is the list of factors of the GCF, which is a quick way to see all of them.

What the GCF is used for

Simplifying fractions. Divide the numerator and denominator by their GCF to reach lowest terms in one step: 36/54 = 2/3. The simplify fractions calculator does this and finds equivalent fractions too.

Splitting into equal groups. With 24 pencils, 36 erasers and 60 stickers, the largest number of identical goodie bags you can make without leftovers is GCF(24, 36, 60) = 12. Each bag gets 2 pencils, 3 erasers and 5 stickers.

Largest square tile. To cover a 12 by 18 foot area with whole square tiles of one size and no cutting, the largest tile is GCF(12, 18) = 6 feet on a side; in inches, 144 and 216 give 72.

Factoring in algebra. To factor 12x + 18, pull out the GCF of the coefficients, 6, to get 6(2x + 3). That is the main use in Elementary Algebra 2e.

Reducing ratios. A 1920 by 1080 screen has a GCF of 120, so its aspect ratio is 16:9.

For two whole numbers, the GCF and the least common multiple are linked: GCF × LCM = a × b. For 54 and 36, 18 × 108 = 1,944, which equals 54 × 36. So once you have the GCF, the LCM is one division away: LCM = a × b ÷ GCF. The least common multiple calculator uses the same relationship. This shortcut only works for two numbers at a time.

Worked examples to practice on

  • GCF(48, 180): 48 = 2⁴ × 3 and 180 = 2² × 3² × 5. Shared: 2² and 3, so the GCF is 12.
  • GCF(84, 120): 84 = 2² × 3 × 7 and 120 = 2³ × 3 × 5. Shared: 2² and 3, so 12 again.
  • GCF(17, 51): 51 = 3 × 17, so the smaller number divides the larger and is itself the GCF, 17.
  • GCF(35, 64): 35 = 5 × 7 and 64 = 2⁶ have no prime in common, so the GCF is 1.
  • GCF(0, 45): every number divides 0, so the GCF is 45. GCF(0, 0) has no meaning and the calculator asks for a positive number.

Cancelling before you multiply fractions

The GCF also keeps fraction multiplication manageable. For 18/35 × 14/27, cancel GCF(18, 27) = 9 and GCF(14, 35) = 7 first: 2/5 × 2/3 = 4/15. Multiplying straight across gives 252/945, which needs the GCF of 63 to reduce to the same 4/15. Both routes are correct; cancelling first keeps the numbers small enough to do in your head.

Signs don’t affect common factors, so the calculator ignores minus signs: GCF(−12, 18) is 6, the same as GCF(12, 18).

Sources & assumptions

How this calculator gets its numbers. Full method: our methodology.

  • Inputs are whole numbers; negative signs are ignored and 0 is allowed alongside a positive number.
  • The GCF is found with Euclid’s algorithm, applied pairwise for more than two numbers.
  • Prime factorizations are shown for numbers above 1; the common factors are the factors of the GCF.
  • Numbers up to one trillion are accepted.

Sources

  1. OpenStax (Rice University), Elementary Algebra 2e, 7.1 Greatest Common Factor and Factor by Grouping. Example 7.1 finds the GCF of 54 and 36 (18) from their prime factors; the section then factors the GCF out of expressions.
  2. OpenStax (Rice University), Prealgebra 2e, 2.5 Prime Factorization and the Least Common Multiple. Prime factorizations of 48, 84 and 120 (Examples 2.48–2.50) and the LCM by listing multiples (15 and 20 → 60) and by prime factors (15 and 18 → 90; 50 and 100 → 100), Examples 2.52–2.54.
  3. NIST Dictionary of Algorithms and Data Structures, Euclid’s algorithm. Definition of Euclid’s algorithm for the greatest common divisor: Euclid(a, b) returns a when b = 0, otherwise Euclid(b, a mod b).

Last reviewed . GCF, GCD and HCF are three names for the same number.

Frequently asked questions

What is the greatest common factor?

It is the largest whole number that divides each of the given numbers with no remainder. The GCF of 54 and 36 is 18.

How do you find the GCF of two numbers?

Factor both into primes and multiply the primes they share, using each at the lowest power. Or divide the larger by the smaller, replace the larger with the remainder, and repeat until the remainder is 0; the last nonzero remainder is the GCF.

What is the GCF of 12 and 18?

The factors of 12 are 1, 2, 3, 4, 6 and 12; the factors of 18 are 1, 2, 3, 6, 9 and 18. The greatest one they share is 6.

What does it mean if the GCF is 1?

The numbers are relatively prime, or coprime. They share no factor other than 1, as with 8 and 15, and a fraction made from them, such as 8/15, is already in simplest form.

Is GCF the same as GCD and HCF?

Yes. Greatest common factor, greatest common divisor and highest common factor are three names for the same number.

How do you find the GCF of three numbers?

Find the GCF of the first two, then the GCF of that answer and the third number. For 12, 18 and 30: GCF(12, 18) = 6, and GCF(6, 30) = 6.