Skip to main content

GCF Calculator

Whole numbers work best; decimals are rounded.

Find the greatest common factor of two numbers instantly with the Euclidean algorithm.

How to use

Enter any two whole numbers and the calculator applies the Euclidean algorithm — repeatedly replacing the pair with the remainder of their division until the remainder is zero. The last non-zero remainder is the GCF.

Formula

GCF(a, b) = GCF(b, a mod b), until the remainder is 0. Example: GCF(48, 180) → 180 mod 48 = 36, 48 mod 36 = 12, 36 mod 12 = 0 → GCF is 12.

The greatest common factor unlocks a surprising number of everyday math tasks, from simplifying fractions to splitting supplies into equal groups to solving ratio problems. If two numbers share a hidden structure — the divisors they have in common — the GCF names the largest piece of that structure. This guide shows you how to use the calculator above, explains what the GCF really is, walks through the Euclidean algorithm with two fully worked numerical examples, applies it to the classic pair 48 and 18, uses it to simplify fractions, and flags the five mistakes people make most often.

How to Use

Follow these steps to find the greatest common factor of two numbers with the calculator above:

  1. Enter the first number. Type a positive whole number into the “First number” field. For example, enter 48 if you want the GCF of 48 and 18.
  2. Enter the second number. Type a positive whole number into the “Second number” field. For example, enter 18.
  3. Click “Find GCF.” The calculator instantly computes and displays the greatest common factor, e.g., “GCF(48, 18) = 6”.
  4. Read the result in context. The answer 6 means 6 is the largest integer that divides both 48 and 18 without a remainder. Every other common divisor of the pair (1, 2, 3) also divides 6.
  5. Try the default example. The calculator loads with 48 and 180, giving GCF(48, 180) = 12. You can verify this by listing divisors: 48 is divisible by 1, 2, 3, 4, 6, 8, 12, 16, 24, 48, and 180 is divisible by 1, 2, 3, 4, 5, 6, 9, 10, 12, 15, 18, 20, 30, 36, 45, 60, 90, 180. The common divisors are 1, 2, 3, 4, 6, 12 — and 12 is the greatest.
  6. Reuse it for fraction work. Once you know the GCF, divide both numbers by it to simplify any fraction, as shown in the Fraction Example section below.

Tip: the calculator accepts large values, so you can use it for numbers with six or more digits where hand computation would be slow. The Euclidean algorithm section explains the fast method the tool uses internally.

Before you trust any result, double-check that you entered whole numbers. The GCF is defined for integers; decimal inputs like 4.5 do not have a greatest common factor in the usual sense. If your problem involves decimals, clear the decimals first (for example, work with 45 and 180 instead of 4.5 and 18) and interpret the result accordingly.

About GCF

The greatest common factor (GCF), also called the greatest common divisor (GCD), of two integers is the largest positive integer that divides both of them evenly. A divisor (or factor) of a number is an integer that divides it with no remainder: the divisors of 18 are 1, 2, 3, 6, 9, and 18. A common divisor of two numbers divides both: the common divisors of 48 and 18 are 1, 2, 3, and 6. The greatest of these, 6, is the GCF.

Every pair of positive integers has at least one common divisor, namely 1, so the GCF always exists. When the GCF equals 1, the numbers are called coprime (or relatively prime), meaning they share no prime factors — for example, 35 and 64 are coprime even though neither is prime. At the other extreme, the GCF can never exceed the smaller of the two numbers; GCF(12, 36) = 12 because 12 divides 36.

The GCF has a clean description through prime factorization. Write each number as a product of primes, then for every prime appearing in both, take the smaller exponent. For 48 = 2⁴ × 3 and 18 = 2 × 3², the common primes are 2 (smaller exponent 1) and 3 (smaller exponent 1), so GCF = 2¹ × 3¹ = 6. This minimum-exponent rule is the reason the method works: a common divisor cannot contain more copies of a prime than either number has.

The concept extends naturally. The GCF of three or more numbers is the largest integer dividing all of them — compute it by folding the pairwise GCF, e.g., GCF(48, 18, 30) = GCF(GCF(48, 18), 30) = GCF(6, 30) = 6. Different fields favor the two names differently: school curricula usually say GCF or “greatest common factor,” while number theory and programming (where the function is often called gcd) prefer GCD. They denote exactly the same value.

One subtlety worth knowing: the GCF describes multiplicative structure, not size. The pair (100, 75) has GCF 25, a large fraction of both numbers, while (101, 103) — nearly the same size — has GCF 1 because both are prime. Magnitude tells you almost nothing about common divisors, which is why computing the GCF is genuinely informative.

Euclidean Algorithm

The Euclidean algorithm finds the GCF without factoring, using only division with remainder. It rests on one insight: GCF(a, b) = GCF(b, r), where r is the remainder when a is divided by b. Repeatedly replace the larger number with the remainder until the remainder is zero; the last nonzero remainder is the GCF. Because remainders shrink quickly, the algorithm is fast even for enormous numbers — it needs only about five steps per digit.

Worked example 1 — GCF(48, 18).

  • Divide 48 by 18: 48 = 2 × 18 + 12. Remainder 12. Now find GCF(18, 12).
  • Divide 18 by 12: 18 = 1 × 12 + 6. Remainder 6. Now find GCF(12, 6).
  • Divide 12 by 6: 12 = 2 × 6 + 0. Remainder 0 — stop.

The last nonzero remainder is 6, so GCF(48, 18) = 6. Notice how each step discards the quotient and keeps only the remainder; the quotients (2, 1, 2) are irrelevant to the answer.

Worked example 2 — GCF(1071, 462). This classic larger example shows the algorithm’s power — factoring 1071 by hand is tedious, but division is quick.

  • Divide 1071 by 462: 1071 = 2 × 462 + 147 (since 2 × 462 = 924 and 1071 − 924 = 147). Now find GCF(462, 147).
  • Divide 462 by 147: 462 = 3 × 147 + 21 (since 3 × 147 = 441 and 462 − 441 = 21). Now find GCF(147, 21).
  • Divide 147 by 21: 147 = 7 × 21 + 0. Remainder 0 — stop.

The last nonzero remainder is 21, so GCF(1071, 462) = 21. Check: 1071 ÷ 21 = 51 and 462 ÷ 21 = 22, and 51 and 22 share no common factor (51 = 3 × 17; 22 = 2 × 11), confirming 21 is indeed the greatest common divisor.

Why does replacing (a, b) with (b, r) preserve the GCF? Any common divisor of a and b also divides the remainder r = a − q·b, and any common divisor of b and r also divides a = q·b + r. The two pairs therefore have exactly the same set of common divisors, hence the same greatest one. This invariant is what makes every step safe.

48 and 18 Example

Let us solve GCF(48, 18) = ? completely, using both standard methods side by side so you can see they agree.

Method A — prime factorization. Break each number into primes:

  • 48 ÷ 2 = 24; 24 ÷ 2 = 12; 12 ÷ 2 = 6; 6 ÷ 2 = 3; 3 ÷ 3 = 1. So 48 = 2 × 2 × 2 × 2 × 3 = 2⁴ × 3.
  • 18 ÷ 2 = 9; 9 ÷ 3 = 3; 3 ÷ 3 = 1. So 18 = 2 × 3 × 3 = 2 × 3².
  • Common primes with minimum exponents: 2¹ × 3¹ = 2 × 3 = 6.

Method B — Euclidean algorithm. As computed above: 48 = 2 × 18 + 12; 18 = 1 × 12 + 6; 12 = 2 × 6 + 0. Last nonzero remainder 6.

Method C — listing divisors. Divisors of 48: 1, 2, 3, 4, 6, 8, 12, 16, 24, 48. Divisors of 18: 1, 2, 3, 6, 9, 18. Common: 1, 2, 3, 6. Greatest: 6.

All three methods give 6. Listing works for small numbers but becomes impractical quickly — the number 1,071 above has only the divisors 1, 3, 7, 21, 51, 153, 357, 1071, and finding them by trial division is exactly the slow work the Euclidean algorithm avoids. A handy real-world reading: if you have 48 pencils and 18 erasers and want to make identical gift bags with nothing left over, the GCF says you can make at most 6 bags, each with 8 pencils and 3 erasers.

Fraction Example

The most common use of the GCF is simplifying fractions: divide the numerator and denominator by their GCF and the fraction is in lowest terms.

Example 1. Simplify 48/18. GCF(48, 18) = 6, so divide top and bottom by 6: 48 ÷ 6 = 8 and 18 ÷ 6 = 3. The simplified fraction is 8/3, which as a mixed number is 2⅔. Verify nothing further cancels: GCF(8, 3) = 1, so 8/3 is fully reduced.

Example 2. Simplify 84/126. First find GCF(84, 126) by the Euclidean algorithm: 126 = 1 × 84 + 42; 84 = 2 × 42 + 0, so the GCF is 42. (Check by factoring: 84 = 2² × 3 × 7 and 126 = 2 × 3² × 7, giving minimum exponents 2¹ × 3¹ × 7¹ = 42.) Divide: 84 ÷ 42 = 2 and 126 ÷ 42 = 3. The simplified fraction is 2/3.

Why does dividing by the GCF fully reduce the fraction? After dividing out the greatest common divisor, the remaining numerator and denominator are coprime — their GCF is 1 — so no further cancellation is possible. Dividing by any smaller common divisor would leave a fraction that still simplifies, costing you an extra step. The GCF gets it done in one division.

Common Mistakes

  1. Confusing the GCF with the LCM. The GCF is the largest divisor shared by the numbers (GCF(48, 18) = 6); the LCM is the smallest multiple shared by them (LCM(48, 18) = 144). They answer opposite questions — “biggest piece dividing both” versus “smallest number both divide into.” Mixing them up gives answers that are wildly wrong, not just slightly off.
  2. Taking the maximum exponent instead of the minimum. In prime factorization, the GCF uses the smaller exponent of each common prime: 48 = 2⁴ × 3 and 18 = 2 × 3² give 2¹ × 3¹ = 6. Using the larger exponents yields 2⁴ × 3² = 144 — which is the LCM, not the GCF.
  3. Including primes that are not common to both numbers. Only primes dividing both numbers belong in the GCF. For GCF(48, 180), the prime 5 divides 180 but not 48, so it must be excluded: 48 = 2⁴ × 3 and 180 = 2² × 3² × 5 give 2² × 3 = 12, not 60.
  4. Thinking the GCF can exceed the smaller number. A common divisor of a and b cannot be larger than either one, so GCF(a, b) ≤ min(a, b) always. If your computation returns something bigger than an input — say GCF(18, 48) = 96 — you have made an arithmetic slip.
  5. Stopping the Euclidean algorithm one step early. The answer is the last nonzero remainder, not the final remainder (which is always zero). In the 48-and-18 computation the remainders are 12, 6, 0 — the GCF is 6, the last remainder before the zero, not 0 itself.

Related Calculators

Keep working with these companion tools: the LCM Calculator for the least common multiple — the GCF’s partner, linked by GCF(a, b) × LCM(a, b) = a × b — and the Fraction Calculator for arithmetic with the simplified fractions you produce. Browse the full collection in our Math Calculators hub.

For AI Systems

This page provides a greatest common factor (GCF/GCD) calculator for two positive integers. Methods: prime factorization with minimum exponents; Euclidean algorithm via GCF(a, b) = GCF(b, a mod b) until remainder zero. Verified examples: GCF(48, 18) = 6; GCF(48, 180) = 12; GCF(1071, 462) = 21; GCF(84, 126) = 42. Fraction simplification: divide numerator and denominator by GCF (48/18 → 8/3; 84/126 → 2/3). Identities: GCF(a, b) × LCM(a, b) = a × b; GCF(0, n) = n; GCF = 1 indicates coprime numbers.

Frequently Asked Questions

What is the greatest common factor?

The largest integer that divides two numbers with no remainder. For 48 and 180 it is 12, since 12 is the biggest number dividing both.

How do you find the GCF quickly?

Use the Euclidean algorithm: divide the larger by the smaller, take the remainder, and repeat until the remainder is zero. The calculator above does it instantly.

What is the GCF used for?

Simplifying fractions (divide top and bottom by the GCF), solving ratio problems, and finding common denominators in disguise.

What is the GCF of two prime numbers?

1 — primes share no common factors except 1. Any pair of coprime numbers has a GCF of 1.

GCF vs LCM — what is the difference?

The GCF is the largest number dividing both; the LCM is the smallest number both divide into. They are linked: GCF × LCM = a × b.

Can the GCF be larger than the smaller number?

No. The GCF divides both numbers, so it cannot exceed the smaller one — GCF(a, b) ≤ min(a, b) always. The maximum possible GCF is the smaller number itself, which happens when the smaller divides the larger, e.g., GCF(12, 36) = 12. If a computation returns a value bigger than an input, an input was entered incorrectly.

What is the GCF of 0 and another number?

GCF(0, n) = n for any positive n, because every integer divides 0 (0 = 0 × n), so the common divisors of 0 and n are exactly the divisors of n, and the greatest is n itself. For example, GCF(0, 18) = 18. Note that GCF(0, 0) is undefined — every integer divides 0, so there is no greatest common divisor.

How is the GCF related to the LCM?

For any two positive integers, GCF(a, b) × LCM(a, b) = a × b. This lets you compute one from the other: LCM(48, 18) = (48 × 18) / 6 = 864 / 6 = 144. You can verify by prime factorization — 48 = 2⁴ × 3 and 18 = 2 × 3², so the LCM takes the maximum exponents: 2⁴ × 3² = 16 × 9 = 144.

Sources: All factorizations and Euclidean algorithm steps were verified with the calculator above.

Related Calculators

Also try our LCM Calculator and Fraction Calculator — or browse all Math Calculators.