ThisCalculator

Math

Greatest Common Factor Calculator & How It Works

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

Greatest Common Factor Calculator & How It Works

This greatest common factor (GCF) calculator finds the largest positive integer that divides two or more given numbers without leaving a remainder. You enter the numbers (separated by commas or spaces), and it instantly returns the GCF, along with the prime factorization of each input so you can verify the result. It handles whole numbers, including negative values (using their absolute value) and zero, using the efficient Euclidean algorithm.

Formula

The calculator uses the Euclidean algorithm, a method known for over 2,000 years. For two positive integers a and b, the algorithm works by repeatedly replacing the larger number with the remainder of dividing the larger by the smaller, until one of them becomes zero. The last non-zero remainder is the GCF.

In mathematical notation:

  • Let a and b be the two input numbers (with a ≥ b).
  • Compute a mod b (the remainder).
  • Replace a with b, and b with the remainder.
  • Repeat until b = 0. The GCF is the last non-zero a.

For more than two numbers, the GCF is found by taking the GCF of the first two, then the GCF of that result with the next number, and so on. The calculator also shows the prime factorization of each input, which is another way to find the GCF by multiplying the lowest power of each common prime factor.

Worked Example

Using the default values from the calculator: 24 and 36.

  1. Divide 36 by 24: quotient 1, remainder 12.
  2. Now divide 24 by 12: quotient 2, remainder 0.
  3. The last non-zero remainder is 12, so GCF(24, 36) = 12.

Check with prime factorization: 24 = 2³ × 3, 36 = 2² × 3². Common primes are 2 (lowest power 2²) and 3 (lowest power 3¹). Multiply: 4 × 3 = 12. The calculator returns 12 as the headline answer.

When to Use the GCF

The greatest common factor appears in many everyday math tasks:

  • Simplifying fractions: Divide the numerator and denominator by their GCF to get the simplest form. For example, 24/36 simplifies to 2/3 because 12 divides both.
  • Distributing or factoring: In algebra, factoring out the GCF from a polynomial (e.g., 6x² + 9x = 3x(2x + 3)) relies on finding the GCF of the coefficients.
  • Solving word problems: Splitting items into equal groups (e.g., dividing 24 apples and 36 oranges into the largest identical gift bags) uses the GCF.
  • Ratio and proportion: Reducing ratios to their simplest form uses the GCF.
  • Least common multiple (LCM): The GCF and LCM are related: for two numbers a and b, LCM(a,b) = (a × b) / GCF(a,b).

How to Read the Result

The result is a single positive integer. If the GCF is 1, the numbers are called relatively prime or coprime—they share no common factors other than 1. For example, GCF(8, 15) = 1 because 8 = 2³ and 15 = 3 × 5.

If one of the inputs is 0, the GCF is the absolute value of the other number (since every number divides 0). If both are 0, the GCF is technically undefined, but the calculator returns 0 for simplicity. Negative numbers are treated as their positive equivalents because the GCF is always positive.

Common Mistakes and Misconceptions

  • Confusing GCF with LCM: The GCF is the largest number that divides all inputs; the LCM is the smallest number that all inputs divide into. For 24 and 36, GCF = 12, LCM = 72. They are different concepts.
  • Using the smaller number as the GCF: This only works if the smaller number divides the larger one exactly. For 24 and 36, 24 does not divide 36, so the GCF is not 24.
  • Ignoring common prime factors: When using prime factorization, you must take the lowest power of each common prime. Taking the highest power gives the LCM instead.
  • Rounding errors: The GCF is always an integer. If you get a decimal, you likely made an arithmetic mistake.
  • Forgetting to check all numbers: For three or more numbers, the GCF must divide every one of them. A common error is to find the GCF of only the first two.

Limits of the Formula

The Euclidean algorithm is extremely fast and works for integers of any size (up to the limits of your device’s memory). However, it only applies to integers. For non-integer inputs (like decimals or fractions), the concept of a greatest common factor is not defined in the usual sense. You could find the GCF of the numerators after converting to a common denominator, but that is a different process.

The calculator also does not handle very large numbers (beyond JavaScript’s safe integer range, about 9 quadrillion) with perfect precision. For numbers larger than that, the result may be approximate. For most practical purposes—schoolwork, everyday math, and basic algebra—this is not an issue.

Alternatives to the Calculator

If you need to find the GCF without a calculator, you have several manual methods:

  • Listing factors: Write all factors of each number and pick the largest one they share. This works well for small numbers but becomes tedious for larger ones.
  • Prime factorization: Break each number into primes, then multiply the common primes with the lowest exponents. This is instructive but can be time-consuming for large numbers.
  • Euclidean algorithm by hand: As shown in the worked example, this is the most efficient manual method and is what the calculator automates.

For finding the GCF of more than two numbers, you can also use the calculator by entering all numbers separated by commas. The algorithm will process them sequentially.

Frequently Asked Questions

What is the difference between GCF and GCD?

GCF (Greatest Common Factor) and GCD (Greatest Common Divisor) are exactly the same thing. Both refer to the largest positive integer that divides two or more numbers without a remainder. The terms are used interchangeably; “factor� is more common in elementary math, while “divisor� appears in number theory.

How do I find the GCF of three numbers?

Find the GCF of the first two numbers, then find the GCF of that result and the third number. For example, GCF(24, 36) = 12, then GCF(12, 48) = 12, so GCF(24, 36, 48) = 12. The calculator does this automatically when you enter more than two numbers.

What is the GCF of 0 and a positive number?

The GCF of 0 and any positive integer n is n, because every positive integer divides 0, and the largest divisor of n is n itself. For example, GCF(0, 15) = 15. If both numbers are 0, the GCF is undefined, but many calculators return 0.

Can the GCF be negative?

No. By definition, the greatest common factor is a positive integer. If you input negative numbers, the calculator uses their absolute values. For instance, GCF(-12, 18) is 6, not -6. This is standard convention in mathematics.

Why is the Euclidean algorithm so fast?

The Euclidean algorithm reduces the problem size dramatically with each step because the remainder is always smaller than the divisor. The number of steps is proportional to the logarithm of the larger number, so even numbers with hundreds of digits can be processed quickly. This is why it remains the standard method in computer science.

What if my numbers are decimals?

The GCF is only defined for integers. If you have decimal numbers, you can multiply all of them by a power of 10 to make them integers, find the GCF of those integers, then divide by the same power of 10. For example, GCF(1.5, 2.5) = GCF(15, 25)/10 = 5/10 = 0.5. However, this calculator expects integer inputs; for decimals, use the manual method.

Related

Formula used
in a | First number | - | 24 | 0
in b | Second number | - | 36 | 0
out gcf | Greatest Common Factor | - | gcf_calc(a, b) | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.