GCF Calculator

Enter two or more positive whole numbers to get their greatest common factor, their least common multiple, and the division steps that lead to the answer.

Two or more positive whole numbers, separated by commas, spaces or new lines.

Result

Greatest common factor (GCF)
42
  • Least common multiple (LCM)1,260
  • Numbers entered3
  • Relatively primeNo
  • Each number ÷ GCF2, 3, 5
  • With more than two numbers, find the GCF of the first two, then the GCF of that result and the next number, and so on.
Running GCF, one number at a time
#NumberGCF so far
18484
212642
321042
GCF(84, 126) = 42
StepDivision (a = q × b + r)
1126 = 1 × 84 + 42
284 = 2 × 42 + 0
GCF(42, 210) = 42
StepDivision (a = q × b + r)
1210 = 5 × 42 + 0

How to use the GCF calculator

Type at least two positive whole numbers into the box. You can separate them with commas, spaces, semicolons or new lines, so pasting a column from a spreadsheet works. Up to 50 numbers are accepted, each with up to 30 digits.

The result shows:

  • the greatest common factor (GCF), the largest number that divides all of your numbers exactly
  • the least common multiple (LCM), the smallest number that all of your numbers divide into
  • whether the numbers are relatively prime (GCF = 1)
  • each number divided by the GCF, which is handy for reducing a fraction or a ratio
  • the full Euclidean algorithm, one line per division

All arithmetic uses exact whole-number math, so even 30-digit inputs give exact answers with no rounding.

The Euclidean algorithm

Listing every factor of a large number is slow. Euclid’s method avoids that by using one fact: the GCF of two numbers does not change if you replace the larger number with the remainder you get when dividing it by the smaller one.

  1. Divide the larger number a by the smaller number b, so that a = q × b + r.
  2. Replace a with b and b with the remainder r.
  3. Repeat until the remainder is 0. The last non-zero remainder is the GCF.

Each step makes the numbers shrink quickly, so even very large inputs need only a few dozen divisions.

For more than two numbers, the calculator works one number at a time: GCF(a, b, c) = GCF(GCF(a, b), c). The running GCF table shows how the answer narrows as each number is added. Once it reaches 1 it cannot change, so later steps are skipped.

The LCM of two numbers comes straight from the GCF: LCM(a, b) = a × b ÷ GCF(a, b). For longer lists the same rule is applied pairwise. The LCM calculator explains that side in more detail.

Worked example: 84, 126 and 210

This is the example loaded when the page opens.

  1. GCF of 84 and 126. 126 = 1 × 84 + 42, then 84 = 2 × 42 + 0. The last non-zero remainder is 42.
  2. GCF of 42 and 210. 210 = 5 × 42 + 0, so the GCF stays 42.
  3. Answer: GCF(84, 126, 210) = 42.

You can check this with prime factors. 84 = 2² × 3 × 7, 126 = 2 × 3² × 7 and 210 = 2 × 3 × 5 × 7. The primes shared by all three, each to its lowest power, are 2 × 3 × 7 = 42. The LCM takes every prime to its highest power: 2² × 3² × 5 × 7 = 1,260. To see the full factorization of any number, use the prime factorization calculator.

Dividing each number by 42 gives 2, 3 and 5, which share no further factor. That is why the ratio 84 : 126 : 210 simplifies to 2 : 3 : 5.

When the GCF is useful

  • Simplifying fractions. Divide the numerator and denominator by their GCF to reach lowest terms in one step, as in the fraction calculator.
  • Reducing ratios to the smallest whole numbers with the ratio calculator.
  • Splitting things evenly, such as cutting two boards of 84 cm and 126 cm into the longest equal pieces with no waste.
  • Tiling a rectangle with the largest possible square tiles.

If you want every factor the numbers share, not just the largest, the common factor calculator lists them all.

Limitations

  • Inputs must be positive whole numbers. Decimals, fractions, zero and negative numbers are rejected with a message explaining why.
  • The list is capped at 50 numbers of up to 30 digits each so the page stays fast. The LCM of many large numbers can be very long, but it is still shown exactly.
  • Division steps are listed for the first six pairs at most; the running GCF table covers longer lists.

Frequently asked questions

Is the GCF the same as the GCD or HCF?

Yes. Greatest common factor, greatest common divisor and highest common factor are three names for the same number, the largest whole number that divides every number in the list with no remainder.

What does a GCF of 1 mean?

The numbers have no factor in common except 1, so they are called relatively prime or coprime. The numbers themselves do not have to be prime: 8 and 15 are both composite, yet their GCF is 1.

How are the GCF and LCM related?

For two positive numbers, the GCF multiplied by the LCM always equals the product of the two numbers. For 18 and 48 that is 6 × 144 = 864 = 18 × 48. The rule does not hold for three or more numbers.

Why can't I include zero or negative numbers?

Every whole number divides zero, so zero adds nothing useful to a list, and a list made only of zeros has no greatest common factor at all. Factors are normally stated for positive numbers, so the calculator asks for positive inputs to keep the results unambiguous.

Last reviewed: