GCF Calculator

Find the greatest common factor of two to six numbers, with Euclid's algorithm worked line by line, the prime factorization of every input, and the matching LCM alongside.

What you get
  • Euclid's algorithm, shownEvery division step printed, not just the answer.
  • Prime factorizationsEach number broken into primes, shared factors highlighted.
  • Up to six numbersAdd or remove inputs; the LCM arrives too.

Your numbers

Results update as you type

Whole numbers from 1 up to 1,000,000,000. The calculator runs Euclid's algorithm, the same steps a Greek geometer used around 300 BC.

Runs entirely in your browser. Nothing you type is sent or saved

GCF guide

What the greatest common factor is

The greatest common factor (GCF), also called the greatest common divisor (GCD), of two or more whole numbers is the largest number that divides every one of them with no remainder. For 48 and 18, the divisors of 48 are 1, 2, 3, 4, 6, 8, 12, 16, 24 and 48, and the divisors of 18 are 1, 2, 3, 6, 9 and 18. The largest number on both lists is 6, so GCF(48, 18) = 6.

Listing divisors works for small numbers, but it becomes hopeless quickly: 1,000,000,000 has far too many divisors to enumerate. Mathematicians use two better methods, and this calculator shows both: Euclid's algorithm, which is astonishingly fast, and prime factorization, which explains why the answer is what it is.

Euclid's algorithm

Recorded in Euclid's Elements around 300 BC, this is one of the oldest algorithms still in daily use. It rests on one observation: any number that divides both a and b also divides their remainder, so the GCF of a and b equals the GCF of b and the remainder of a ÷ b. Repeat until the remainder hits zero, and the last nonzero remainder is the answer:

gcf(a, b) = gcf(b, a mod b)

repeat until the remainder is 0; the last divisor is the GCF

Worked with 48 and 18:

48 = 2 × 18 + 12
18 = 1 × 12 + 6
12 = 2 × 6 + 0, so the GCF is 6

Three lines, even though listing divisors of 48 took ten. The algorithm is dramatically faster on big numbers: the worst case (consecutive Fibonacci numbers) still finishes in a handful of steps, which is why the calculator can handle inputs up to a billion instantly.

The prime factorization method

Every whole number above 1 factors into primes in exactly one way. Break each number down, take every prime that appears in all the factorizations, and multiply the smallest power of each:

  • 48 = 24 × 3
  • 18 = 2 × 32
  • Shared primes, lowest powers: 21 × 31 = 6

Both methods agree, as they must. Prime factorization is the slower route for big inputs, but it makes the structure visible: you can see exactly which primes the numbers share. This calculator prints the full factorization of every input with the shared primes marked, alongside Euclid's fast answer.

Three or more numbers

The GCF extends to any count by pairing: compute the GCF of the first two, then the GCF of that result with the third, and so on. For 12, 18 and 30:

gcf(12, 18) = 6
gcf(6, 30) = 6, so the GCF of all three is 6

Check by prime factorization: 12 = 22 × 3, 18 = 2 × 32, 30 = 2 × 3 × 5. The primes present in all three are 2 and 3, each to the first power, and 2 × 3 = 6. The calculator takes up to six numbers and applies exactly this chaining, showing the running result after each.

Coprime numbers

When the GCF is 1, the numbers are called coprime (or relatively prime). They share no prime building blocks at all, even though each may be highly composite on its own: 8 = 23 and 15 = 3 × 5 share nothing, so GCF(8, 15) = 1. Consecutive integers are always coprime, and so are two distinct primes.

Coprimality is a useful property, not a failure to find a factor. Fractions in lowest terms have coprime numerator and denominator, and the LCM of coprime numbers is simply their product: lcm(8, 15) = 120.

Why the GCF matters

  • Simplifying fractions: divide the top and bottom by their GCF and the fraction is in lowest terms. 48/18 ÷ 6/6 = 8/3, and no smaller equivalent exists.
  • Tiling and cutting: the largest square tile that evenly covers a 48 by 18 foot floor is 6 by 6 feet, because 6 is the GCF of the sides. The same logic sizes equal pieces from boards of unequal length with no waste.
  • Scheduling and packing: grouping 48 of one item and 18 of another into the largest identical sets means sets of 6.
  • Algebra: factoring out the GCF is the first step of polynomial factoring, and the GCF of numerator and denominator keeps the quadratic formula's fractions tidy.
GCF vs LCM: the GCF divides the numbers; the LCM is divided by them. For 48 and 18 the GCF is 6 and the LCM is 144, and they are linked by the identity gcf(a, b) × lcm(a, b) = a × b: 6 × 144 = 864 = 48 × 18. The calculator shows the LCM beside every answer for exactly this cross-check.

Using the calculator well

  • Whole numbers only: the GCF is defined for positive integers. Decimals and negatives are rejected; if your numbers carry units, strip them first (the GCF of 48 cm and 18 cm is 6 cm).
  • Order never matters: Euclid's algorithm converges to the same answer whichever number leads, so enter the numbers in any order.
  • Read both methods: Euclid gives the answer fast; the prime table shows why. If the GCF equals one of your inputs, that number divides all the others exactly.
  • Use the LCM cross-check: for two numbers, gcf × lcm always equals the product of the inputs. If it does not, a typo is hiding somewhere.
  • Coprime results are legitimate: a GCF of 1 with large inputs is a real answer, not an error. It says the numbers share no prime factors.

Common questions

The greatest common factor is the largest number that divides all your inputs, so it is never bigger than the smallest input. The least common multiple is the smallest number all inputs divide into, so it is never smaller than the largest input. For 48 and 18 they are 6 and 144 respectively, and the two are tied by gcf times lcm equals the product of the inputs.

It means the numbers are coprime: they share no prime factor at all. The inputs 8 and 15 have GCF 1 even though both are composite, because 8 is built from 2s and 15 from 3 and 5. A GCF of 1 also tells you a fraction like 8/15 is already in lowest terms.

Each division at least halves the smaller number, so the number of steps grows with the number of digits, not with the size of the values. Even two numbers near a billion finish in a few dozen divisions, while listing every divisor of a billion would take millions of checks. That efficiency is why the 2,300-year-old algorithm still runs inside modern cryptography libraries.

Divide the numerator and the denominator by their GCF. For 48/18, the GCF is 6, so 48 ÷ 6 = 8 and 18 ÷ 6 = 3, giving 8/3. Because you removed the largest shared factor at once, the result is guaranteed to be in lowest terms, and no further simplification is possible.

Yes. Chain the pairwise result: gcf(a, b, c) = gcf(gcf(a, b), c). For 12, 18 and 30, gcf(12, 18) is 6 and gcf(6, 30) is also 6, so the answer is 6. This calculator accepts up to six numbers and applies the same chaining automatically.

That means the smaller number divides the larger one exactly, and it is the largest such factor. For 12 and 36 the GCF is 12, because 36 is three times 12. It is a useful signal: whenever the GCF equals the smallest input, every number in your set is a multiple of it.

Yes, the two names describe the same number: the largest value dividing all the inputs. GCF is the usual classroom name and GCD is the usual mathematics and programming name. Textbooks also use HCF, highest common factor, in some countries, and it means the same thing again.

No. Every calculation runs in your browser. Nothing is stored or transmitted.

The oldest algorithm, working instantly.

Browse all math calculators