GCF Calculator

Enter two to six positive whole numbers separated by commas and get the greatest common factor, the least common multiple, every factor of each number, and the step-by-step working for both the prime factorization method and the Euclidean algorithm.

Put this calculator on your website for free

Copy one snippet and give your visitors a working GCF Calculator.

How this GCF calculator works

Type in your numbers and you get four things at once: the greatest common factor (GCF), the least common multiple (LCM), the complete list of factors for each number, and the prime factorization of each number. You also get the working, step by step, with your actual numbers substituted in. There are two classic ways to find a GCF, and the radio above lets you pick which one the steps walk through.

The GCF (also called the GCD or HCF, same thing) is the largest number that divides evenly into every number you entered. The LCM is the smallest number that every number you entered divides into evenly. They answer opposite questions, and together they cover most of what factoring gets used for: simplifying fractions, adding fractions, splitting things into equal groups, and finding when repeating cycles line up.

The formula

GCF(a, b): repeat a = b × q + r until r = 0; the last nonzero remainder is the GCF
GCF(a, b) × LCM(a, b) = a × b

In the first line (the Euclidean algorithm), a is the larger number, b is the smaller, q is the whole-number quotient, and r is the remainder. Each round, the pair (a, b) becomes (b, r), and the numbers shrink fast. The second line is the identity linking GCF and LCM for any two positive whole numbers: once you know one, a single division gives you the other.

Method 1: prime factorization

Break each number down into primes, then keep only the primes that appear in every factorization, each raised to the lowest power it reaches. Multiply those together and you have the GCF. For the LCM, do the mirror image: take every prime that appears anywhere, each at its highest power.

This method is worth learning because it shows you why the answer is what it is. The GCF is literally the overlap of the numbers' prime ingredients. Its weakness is practical: factoring big numbers is slow, for you and (at truly large scales) for computers too. That difficulty is not a quirk; it is the foundation of modern encryption.

Method 2: the Euclidean algorithm

Euclid published this procedure around 300 BC in the Elements, Book VII, which makes it roughly 2,300 years old. It is often called the oldest algorithm still in everyday use, and here is the remarkable part: nobody has found a fundamentally faster general method since. Your phone runs it (or a close variant) every time it negotiates an encrypted connection. Very few ideas in any field survive 23 centuries without being replaced.

The insight is simple and lovely: any number that divides both a and b must also divide their remainder when you divide one by the other. So GCF(a, b) = GCF(b, r), and you can keep replacing the big problem with a strictly smaller one until the remainder hits 0. No factoring required, which is why it stays fast even for numbers with hundreds of digits. Try it above on 1071 and 462 and watch it land on 21 in three lines.

Worked example

Find the GCF and LCM of 24 and 36.

Prime factorization method: 24 = 2^3 x 3 and 36 = 2^2 x 3^2. The common primes are 2 and 3; take the lowest power of each: 2^2 x 3 = 12. For the LCM take the highest powers: 2^3 x 3^2 = 72.

Euclidean algorithm: 36 = 24 x 1 + 12, then 24 = 12 x 2 + 0. The last nonzero remainder is 12, so GCF = 12.

Check with the identity: GCF x LCM = 12 x 72 = 864 = 24 x 36.

What the GCF is actually for: simplifying fractions

The single most common real use of the GCF is reducing a fraction in one step. Divide the top and bottom by their GCF and you are done: 24/36 becomes 2/3 because the GCF of 24 and 36 is 12. Divide by anything smaller (say, 2) and you will have to keep going. The GCF is the one divisor that finishes the job immediately.

The LCM handles the other half of fraction work: adding and subtracting. To add 1/24 and 1/36 you need a common denominator, and the LCM (72) is the smallest one that works. Using the LCM instead of just multiplying the denominators together keeps the numbers small and the final answer already reduced, or close to it.

One caution worth stating plainly: a GCF of 1 does not mean anything went wrong. It means your numbers are coprime, sharing no factor beyond 1, and the fraction they form is already in lowest terms.

Frequently asked questions

What is the GCF of 24 and 36?

The GCF of 24 and 36 is 12. The factors of 24 are 1, 2, 3, 4, 6, 8, 12, 24 and the factors of 36 are 1, 2, 3, 4, 6, 9, 12, 18, 36. The largest number on both lists is 12.

How do I find the GCF of two numbers?

The fastest way is the Euclidean algorithm: divide the larger number by the smaller, keep the remainder, then divide the smaller number by that remainder, and repeat until the remainder is 0. The last nonzero remainder is the GCF. For 36 and 24: 36 = 24 x 1 + 12, then 24 = 12 x 2 + 0, so the GCF is 12.

What is the difference between GCF and LCM?

The GCF is the largest number that divides evenly into all of your numbers; the LCM is the smallest number that all of your numbers divide evenly into. The GCF is always at most the smallest input, and the LCM is always at least the largest. For two numbers they are linked by the identity GCF x LCM = a x b.

What does it mean if the GCF is 1?

It means the numbers are coprime (also called relatively prime): they share no common factor other than 1. It does not mean either number is prime. For example, 8 and 9 are both composite, but their GCF is 1 because 8 = 2^3 and 9 = 3^2 share no prime.

Is GCF the same as GCD and HCF?

Yes. Greatest common factor (GCF), greatest common divisor (GCD), and highest common factor (HCF) are three names for exactly the same number. GCF is common in American schools, GCD in higher math and programming, and HCF in British and Indian textbooks.

How is the GCF used to simplify fractions?

Divide the numerator and the denominator by their GCF and the fraction is fully reduced in one step. To simplify 24/36, the GCF of 24 and 36 is 12, so 24/36 = (24 / 12) / (36 / 12) = 2/3. No further reduction is possible because 2 and 3 are coprime.

Related calculators