Skip to main content
Viralrang
MathFree · no sign-up

GCF Calculator

Greatest common factor, with the prime factorisation of every number shown.

Updated

2 numbers found. Two or more whole numbers. Decimals are ignored.

Greatest common factor

6

The largest whole number that divides all 2 of them.

Prime factors of the GCF
2 × 3
Least common multiple
36
How many common divisors
4

Every common divisor

1236

Prime factorisation of each

  • 12 = 2 × 2 × 3
  • 18 = 2 × 3 × 3

The GCF is what you get by taking every prime the numbers have in common, each to the lowest power any of them uses, and multiplying. Everything in the list above is a divisor of the GCF — that is not a coincidence, it is why the GCF is the greatest one.

For two numbers, GCF × LCM always equals their product: 6 × 36 = 12 × 18. The identity is a pair identity only — it does not extend to three or more.

In short

How do you find the greatest common factor?

Break each number into its prime factors and multiply the ones they share. For 12 and 18 that is 2 × 2 × 3 and 2 × 3 × 3, sharing one 2 and one 3, so the greatest common factor is 6. The Euclidean algorithm gets there faster on large numbers.

Every common divisor of two numbers divides their GCF. That is what makes it the greatest one.

How to use the GCF calculator

The greatest common factor of a set of whole numbers is the largest number that divides all of them without remainder. It is what reduces a fraction to lowest terms in one step, what simplifies a ratio, and what tells you the largest identical group you can split several quantities into. Two methods find it, and they suit different sizes of number.

The first is prime factorisation. Break each number into primes, find the ones they have in common, and multiply those together. Twelve is 2 × 2 × 3 and eighteen is 2 × 3 × 3; both contain a 2 and a 3, and neither contains a second shared factor, so the answer is 6. This method shows why the answer is what it is, which makes it the one worth learning first.

6

GCF of 12 and 18

one shared 2, one shared 3

1

GCF of coprime numbers

they share nothing above 1

36

Their LCM

and 6 × 36 = 12 × 18

The second method is the Euclidean algorithm, and it is enormously faster on large numbers because it never factorises anything. Divide the larger by the smaller and keep the remainder. Then divide the previous divisor by that remainder. Repeat until the remainder is zero, and the last non-zero remainder is the greatest common factor.

One property is worth knowing because it doubles as a check: every number that divides both inputs also divides their greatest common factor. So for 12 and 18 the common divisors are 1, 2, 3 and 6 — exactly the divisors of 6, and nothing else. If your candidate answer has a common divisor larger than itself, it was not the greatest.

What the GCF is used for
Reducing a fraction
divide top and bottom by it
Simplifying a ratio
divide every term by it
Splitting quantities into equal groups
the largest group size that works
Factoring an expression
the common factor pulled outside the bracket
Tiling a rectangle with squares
the largest square that fits both sides

The last one is the geometric picture behind Euclid's own construction: the greatest common measure of two lengths is the largest unit that measures both exactly.

The other half of the pair

Every GCF has a matching least common multiple, and for two numbers the two are locked together by an exact identity. That page works it the other way.

Open the LCM calculator

Greatest common factors and least common multiples for common pairs, with the product identity shown so it can be checked rather than trusted.

NumbersGCFLCM
12 and 18636
4 and 6212
8 and 12424
9 and 281252
15 and 25575
21 and 6342
100 and 7525300
270 and 19268,640
7 and 13191
48 and 18012720
8, 12 and 204120
For every pair here, GCF × LCM equals the product of the two numbers. That relationship holds for pairs only.

The identity that ties GCF to LCM, and its limit

For any two whole numbers, the greatest common factor multiplied by the least common multiple equals the product of the numbers themselves. For 12 and 18 that is 6 × 36 = 216, and 12 × 18 = 216. It is a genuinely useful shortcut: find one and the other falls out of a single division.

Why the shortcut stops at two numbers
For 12 and 18
gcf 6, lcm 36
Product of the two
6 × 36 = 216
Product of the inputs
12 × 18 = 216
Now try 2, 4 and 8
gcf 2, lcm 8
Their product
2 × 8 = 16
But 2 × 4 × 8 is
64, not 16

The identity is a pair identity and does not generalise. Extending it to three or more numbers is a common error and gives an answer that is wrong by a wide margin — here by a factor of four. With more than two values, fold pairwise instead.

That pairwise fold is also how this page computes the least common multiple of a longer list: take the LCM of the first two, then of that result and the third, and so on. It keeps every intermediate value at or below the final answer, whereas multiplying everything first can overflow before the division brings it back.

Euclid's algorithm, still the fastest thing available

The method appears in the Elements, where Book VII Proposition 2 gives the construction for finding the greatest common measure of two numbers that are not relatively prime. It is one of the oldest algorithms still in everyday use, and nothing has replaced it — modern cryptography runs it on numbers hundreds of digits long.

Do

  • Use prime factorisation to understand why, and Euclid to go fast
  • Check that every common divisor divides your answer
  • Fold pairwise when there are more than two numbers
  • Treat GCF, GCD and HCF as the same quantity

Don't

  • Extend gcf × lcm = a × b beyond two numbers
  • Assume the GCF is one of the numbers you entered
  • Try to factorise very large numbers when Euclid will do
  • Include zero in a list you also want an LCM from

Its speed comes from never needing to know the factors. Factorising a large number is genuinely hard — the difficulty is what much of public-key cryptography rests on — while Euclid finds the greatest common factor of two enormous numbers in a few dozen steps without discovering a single prime.

The formula, worked line by line

Two methods and one identity. The identity is the shortcut, the prime factorisation is the explanation, and Euclid is what you use when the numbers get large enough that factorising stops being practical.

Every common divisor divides the greatest one. That is not a curiosity — it is what "greatest" means here, and it doubles as a check on your answer.
The property that defines the GCF

It also explains why listing the common divisors is never wasted work. They are precisely the divisors of the answer, so producing them confirms the answer at the same time.

gcf = product of the primes shared by every number
Euclid: gcd(a, b) = gcd(b, a mod b), until the remainder is 0
gcf(a, b) × lcm(a, b) = a × b, for two numbers only
lcm(a, b) = a × b ÷ gcf(a, b)
common divisors of a and b = divisors of gcf(a, b)
The greatest common factor is the shared primesTwelve and eighteen share one 2 and one 3, so their greatest common factor is 6. Every common divisor — 1, 2, 3, 6 — divides that answer.TAKE THE PRIMES THEY BOTH HAVE12= 2 × 2 × 318= 2 × 3 × 3shared2 × 3 = 6every common divisor1 2 3 6AND ITS PAIRgcf6lcm36gcf × lcm21612 × 18216
Twelve and eighteen broken into primes, with the shared ones multiplied out.
Euclid on 270 and 192
270 ÷ 192
remainder 78
192 ÷ 78
remainder 36
78 ÷ 36
remainder 6
36 ÷ 6
remainder 0
Last non-zero remainder
6

Four divisions, no factorisation. Doing this by prime factors would mean breaking 270 into 2 × 3³ × 5 and 192 into 2⁶ × 3 first, which is more work here and rapidly becomes impossible as the numbers grow.

When the answer is 1

Two numbers whose greatest common factor is 1 are called coprime, or relatively prime. It does not mean either of them is prime — 9 and 28 are coprime and neither is a prime number. It means they share no building blocks: 9 is 3 × 3 and 28 is 2 × 2 × 7, with nothing in common at all.

Where the standards put it

The same idea under three names
Greatest common factor (GCF)
US Common Core, grade 6
Highest common factor (HCF)
England, key stage 3
Greatest common divisor (GCD)
number theory, and NIST
Common Core requirement
GCF of two numbers up to 100
And
LCM of two numbers up to 12

The Common Core standard is 6.NS.B.4, which also asks students to use the distributive property with a common factor — rewriting 36 + 8 as 4 × (9 + 2), which is the GCF doing its other job.

That second job is the one that carries into algebra. Factoring an expression means finding the greatest common factor of its terms and pulling it outside a bracket, which is the same operation performed on symbols instead of numbers.

Questions people ask

Sources

Where the constants and formulas on this page come from. Each line names the figure it backs.

  1. Students find the greatest common factor of two whole numbers up to 100 and the least common multiple of two whole numbers up to 12, and use the distributive property with a common factor.

    CCSS.Math.Content.6.NS.B.4Common Core State Standards Initiative

  2. Euclid gives the construction for the greatest common measure of two numbers in Elements Book VII, Proposition 2.

    Euclid's Elements, Book VII, Proposition 2Clark University, D. E. Joyce

  3. The greatest common divisor of two integers is the largest integer dividing both, and the Euclidean algorithm computes it by repeated remainder.

    Euclidean AlgorithmWolfram MathWorld

How Are Loan Payments Calculated? Amortization, Explained

One level payment, front-loaded interest — the formula worked by hand, the two levers you control, and why the smaller payment is often the costlier loan.

July 23, 2026 · 13 min read

How Does Inflation Work? The Math That Shrinks Money

One growth factor, two answers — what today's money will buy later, and how many future dollars it takes to keep up.

July 23, 2026 · 13 min read

How Is Sales Tax Calculated? Rates, Rules, and the Reverse Math

The combined-rate reality, the one-multiplication forward formula, and the division that pulls the tax back out of any total.

July 23, 2026 · 13 min read