GCF Calculator

GCF Calculator

Popular AI Skill PRO

Enter Calculation

Formula

GCF=gcd⁡(Numbers)\text{GCF} = \gcd\left(\text{Numbers}\right)
Usage stats

Advertisement

Results

Greatest Common Factor
12
Prime factorization
24 23 × 3
36 22 × 32
Common prime factors 22 × 3 = 12

Report an error on this page

What the GCF Calculator Does

The Greatest Common Factor (GCF) — also called the greatest common divisor (GCD) — is the largest whole number that divides evenly into every number in a set. This calculator takes a list of integers you type in and instantly returns the single biggest factor they all share. It is handy for simplifying fractions, reducing ratios, factoring algebra problems, and splitting quantities into equal groups.

How to Use It

There is just one input field, labelled numbers. Enter two or more whole numbers separated by commas, for example 24, 36, 60. The tool then:

  • Splits your text on each comma and trims any extra spaces.
  • Keeps only valid integers — it matches the pattern -?\d+, so negative numbers are accepted but decimals, fractions and stray text are ignored.
  • Calculates the GCF across all the valid numbers and shows the result.

Because non-integer entries are simply filtered out, a tidy comma-separated list gives the most reliable answer.

The Formula Behind It

The calculator does not test every possible divisor. Instead it applies the Euclidean algorithm to two numbers at a time and "folds" the list together. In plain terms it computes:

$$\text{GCF} = \gcd\left(\text{Numbers}\right)$$
  • GCF(a, b) using the classic gcd routine.
  • Then GCF(that result, c), then GCF(that result, d), and so on for the whole list.

This works because the GCF of several numbers equals the GCF of the running result and the next number — an efficient, well-proven approach.

Advertisement
Two numbers broken into prime factors with shared factors highlighted
The GCF is the product of the prime factors shared by all numbers.

Worked Example

Suppose you enter 24, 36, 60:

  • \(\gcd(24, 36) = 12\)
  • \(\gcd(12, 60) = 12\)

So the calculator returns 12. You can confirm it: \(24 \div 12 = 2\), \(36 \div 12 = 3\), and \(60 \div 12 = 5\), all whole numbers, and no larger value divides all three.

Venn diagram of prime factors of two numbers with overlap as the GCF
Common prime factors lie in the overlap; their product is the GCF.

How to Find the GCF by Hand

The greatest common factor (GCF) of a set of integers is the largest positive integer that divides every one of them with no remainder. Three hand methods give the same answer; pick the one that fits the size of your numbers.

Method 1 — Prime factorization

  1. Write each number as a product of primes. Example: \(24 = 2^3 \cdot 3\) and \(36 = 2^2 \cdot 3^2\).
  2. Keep only the primes that appear in every factorization. Here both contain 2 and 3.
  3. Give each shared prime its lowest exponent across the numbers: \(2^{\min(3,2)} = 2^2\) and \(3^{\min(1,2)} = 3^1\).
  4. Multiply those powers together: $$\gcd(24,36) = 2^2 \cdot 3 = 4 \cdot 3 = \text{12}$$ so the GCF is 12.
  5. If no prime is shared by all numbers, the GCF is 1.

Method 2 — Euclidean algorithm (best for large numbers)

The Euclidean algorithm avoids factoring entirely. It rests on the fact that \(\gcd(a,b) = \gcd(b,\; a \bmod b)\).

  1. Divide the larger number by the smaller and keep the remainder.
  2. Replace the larger number with the smaller, and the smaller with the remainder.
  3. Repeat until the remainder is 0. The last nonzero remainder is the GCF.

For \(\gcd(1071, 462)\):

  1. \(1071 = 2 \times 462 + 147\)
  2. \(462 = 3 \times 147 + 21\)
  3. \(147 = 7 \times 21 + 0\)
  4. Remainder 0 reached, so the last nonzero remainder, 21, is the GCF.

Method 3 — Listing factors (small numbers only)

Write every factor of each number, circle the ones they share, and take the largest. Factors of 18: 1, 2, 3, 6, 9, 18. Factors of 30: 1, 2, 3, 5, 6, 10, 15, 30. Common factors: 1, 2, 3, 6 → GCF = 6. This is reliable but slow once numbers exceed two digits.

Three or more numbers — the fold rule

The GCF is associative, so you can reduce a long list two numbers at a time:

$$\gcd(a,b,c) = \gcd\bigl(\gcd(a,b),\, c\bigr)$$

For example, \(\gcd(30, 42, 70)\): first \(\gcd(30,42) = 6\), then \(\gcd(6,70) = 2\). The order of folding does not change the result. Because each fold can only shrink the running value, you can stop early the moment the running GCF reaches 1.

Sign does not matter: divisibility ignores sign, so \(\gcd(-a,b) = \gcd(a,b)\) and the GCF is always reported as a positive number.

Key Terms and Definitions

Term Definition
Factor (divisor) An integer that divides another integer exactly, leaving remainder 0. For example, 7 is a factor of 42 because \(42 = 7 \times 6\).
Common factor A number that is a factor of every number in the set. 1 is a common factor of any set of integers.
Greatest common factor (GCF) The largest positive integer that divides all numbers in the set. Also called the greatest common divisor (GCD) or, in British and Indian textbooks, the highest common factor (HCF) — the three names mean exactly the same thing.
Prime number An integer greater than 1 whose only positive factors are 1 and itself: 2, 3, 5, 7, 11, 13, … Note that 1 is not prime.
Composite number An integer greater than 1 that is not prime, i.e. it has at least one factor other than 1 and itself.
Prime factorization Writing a number as a product of primes, e.g. \(360 = 2^3 \cdot 3^2 \cdot 5\). By the fundamental theorem of arithmetic this decomposition is unique apart from the order of the factors.
Coprime (relatively prime) Two or more numbers whose GCF is 1, such as 14 and 25. They share no prime factor, even though neither one has to be prime itself.
Least common multiple (LCM) The smallest positive integer that every number in the set divides into, e.g. \(\operatorname{lcm}(4,6) = 12\).
Lowest terms A fraction is in lowest terms when the GCF of its numerator and denominator is 1.

Two identities worth memorizing

For any two nonzero integers \(a\) and \(b\), the product of the GCF and the LCM equals the absolute value of the product:

$$\gcd(a,b) \times \operatorname{lcm}(a,b) = |a \times b|$$

So once you know the GCF you get the LCM for free: with \(a = 24\), \(b = 36\) and \(\gcd = 12\), we get \(\operatorname{lcm} = (24 \times 36) / 12 = 864 / 12 = 72\). Careful: this identity holds for two numbers only — it does not extend unchanged to three or more.

The second identity handles zero: every integer divides 0, so

$$\gcd(a, 0) = |a|, \qquad \gcd(0,0) = 0$$

This is why adding a 0 to your list never changes the answer, and why \(\gcd(0,0)\) is defined as 0 by convention.

Advertisement

More Worked Examples

Example 1 — A coprime pair: gcd(14, 25)

Prime factorization: \(14 = 2 \cdot 7\) and \(25 = 5^2\). The two lists share no prime at all, so the only common factor is 1.

Checking with the Euclidean algorithm:

  1. \(25 = 1 \times 14 + 11\)
  2. \(14 = 1 \times 11 + 3\)
  3. \(11 = 3 \times 3 + 2\)
  4. \(3 = 1 \times 2 + 1\)
  5. \(2 = 2 \times 1 + 0\)

The last nonzero remainder is 1, so \(\gcd(14,25) = 1\) and the numbers are coprime. A fraction such as \(\tfrac{14}{25}\) is therefore already in lowest terms.

Example 2 — Simplifying the fraction 84/126

  1. Factor both parts: \(84 = 2^2 \cdot 3 \cdot 7\), \(126 = 2 \cdot 3^2 \cdot 7\).
  2. Shared primes at their lowest exponents: \(2^1 \cdot 3^1 \cdot 7^1\).
  3. Multiply: \(2 \cdot 3 \cdot 7 = 42\), so the GCF is 42.
  4. Divide numerator and denominator by 42: $$\frac{84}{126} = \frac{84 \div 42}{126 \div 42} = \frac{2}{3}$$

Because \(\gcd(2,3) = 1\), the result is fully reduced. Dividing by anything smaller than the GCF — say 6, giving \(\tfrac{14}{21}\) — leaves work still to do.

Example 3 — A mixed set with a negative: gcd(−18, 45, 9)

Signs are dropped first, since divisibility does not depend on sign: the task becomes \(\gcd(18, 45, 9)\). Now fold left to right.

  1. \(\gcd(18,45)\): \(45 = 2 \times 18 + 9\), then \(18 = 2 \times 9 + 0\) → GCF is 9.
  2. Fold in the third number: \(\gcd(9, 9) = 9\).

So \(\gcd(-18, 45, 9) = \) 9. The answer is positive even though one input was negative, and here the GCF equals one of the inputs — that always happens when one number divides all the others.

Example 4 — Four numbers: gcd(48, 72, 120, 180)

By prime factorization. Factor each:

Number Prime factorization Power of 2 Power of 3 Power of 5
48 \(2^4 \cdot 3\) \(2^4\) \(3^1\) —
72 \(2^3 \cdot 3^2\) \(2^3\) \(3^2\) —
120 \(2^3 \cdot 3 \cdot 5\) \(2^3\) \(3^1\) \(5^1\)
180 \(2^2 \cdot 3^2 \cdot 5\) \(2^2\) \(3^2\) \(5^1\)

The prime 5 is missing from 48 and 72, so it is excluded. The shared primes at their lowest exponents give

$$\gcd(48,72,120,180) = 2^2 \cdot 3 = 4 \cdot 3 = 12$$

By the Euclidean fold. Using \(\gcd(a,b,c,d) = \gcd(\gcd(\gcd(a,b),c),d)\):

  1. \(\gcd(48,72)\): \(72 = 1 \times 48 + 24\); \(48 = 2 \times 24 + 0\) → 24.
  2. \(\gcd(24,120)\): \(120 = 5 \times 24 + 0\) → 24.
  3. \(\gcd(24,180)\): \(180 = 7 \times 24 + 12\); \(24 = 2 \times 12 + 0\) → 12.

Both routes agree: the GCF is 12. Sanity check the answer by dividing: 48/12 = 4, 72/12 = 6, 120/12 = 10, 180/12 = 15 — all whole numbers, and \(\gcd(4,6,10,15) = 1\), confirming nothing larger was missed.

Conventions and edge cases

Each case below was run through this calculator; the result column is what it actually returns.

CaseInputResult
With a negative number (−12 and 18)-12, 18GCF = 6
With a zero (0 and 12)0, 12GCF = 12

Checked on 2026-11-08

FAQ

Can I enter just one number? Yes — the GCF of a single number is that number itself, since it is its own largest factor.

What about negative numbers? Negatives are allowed. The GCF is always reported as a positive value, because divisibility ignores sign (for example, \(\gcd(-8, 12) = 4\)).

Why was my decimal ignored? The tool only reads whole integers. Any value with a decimal point, or non-numeric text, is filtered out before the calculation, so stick to integers separated by commas.

Last updated:

Most popular in Math and Statistics

View all Math and Statistics calculators