Math

GCF Calculator (Greatest Common Factor)

Settings
Reset
Share
Save
Embed
Report a bug

Share calculator

Add our free calculator to your website

Please enter a valid URL. Only HTTPS URLs are supported.


Use as default values for the embed calculator what is currently in input fields of the calculator on the page.


Input border focus color, switchbox checked color, select item hover color etc.


Please agree to the Terms of Use.

Preview

Save calculator

Calculator Settings

Please enter a value within the allowed range.

Please enter a value within the allowed range.

Please enter a value within the allowed range.

Please enter a value within the allowed range.

Share calculator

What is the greatest common factor?

The greatest common factor (GCF), also called the greatest common divisor (GCD) or highest common factor, is the largest positive integer that divides every number in a given set without leaving a remainder. For example, the GCF of 12 and 18 is 6, because 6 is the biggest number that divides both 12 and 18 evenly.

This calculator finds the GCF of two or more positive integers. As a bonus, it also reports the least common multiple (LCM): the smallest positive integer that is a multiple of every number in the set.

How does the calculator work?

Enter your numbers in the repeatable rows — add as many as you need. The calculator ignores any blank rows and requires at least two numbers to produce a result. It then folds the Euclidean algorithm over the whole list to get the GCF, and uses that result to compute the LCM.

The Euclidean algorithm finds the GCF of two numbers by repeatedly replacing the larger number with the remainder of dividing the larger by the smaller, until the remainder is zero. The last non-zero value is the GCF. To handle a whole list, the GCF is computed pairwise: gcd(a, b, c) = gcd(gcd(a, b), c), and so on.

Formulas

The GCF of a list of numbers is computed by folding the pairwise GCD:

GCF(a1,a2,,an)=gcd(gcd(gcd(a1,a2),a3),an)\text{GCF}(a_1, a_2, \ldots, a_n) = \gcd(\ldots\gcd(\gcd(a_1, a_2), a_3)\ldots, a_n)

The LCM of two numbers follows directly from their GCF:

lcm(a,b)=a×bgcd(a,b)\text{lcm}(a, b) = \frac{a \times b}{\gcd(a, b)}

Worked examples

  1. Two numbers: gcd(12,18)=6\gcd(12, 18) = 6 and lcm(12,18)=36\text{lcm}(12, 18) = 36. The factors of 12 are 1, 2, 3, 4, 6, 12 and of 18 are 1, 2, 3, 6, 9, 18; the largest factor they share is 6.

  2. Three numbers: gcd(8,12,16)=4\gcd(8, 12, 16) = 4. Every one of 8, 12, and 16 is divisible by 4, and nothing larger divides all three.

  3. Coprime numbers: gcd(7,13)=1\gcd(7, 13) = 1. Both 7 and 13 are prime, so they share no common factor other than 1 — they are coprime.

  4. Larger set: gcd(100,75,50)=25\gcd(100, 75, 50) = 25. The number 25 divides all three, while 50 does not divide 75.

Practical notes

  • Simplifying fractions: Dividing the numerator and denominator by their GCF reduces a fraction to lowest terms. See the simplify fractions calculator.
  • Adding fractions: The LCM of the denominators gives the least common denominator, which makes adding fractions straightforward — useful alongside the addition calculator.
  • Only positive integers: The GCF is defined for whole numbers. Decimals and negative signs are not meaningful here, so non-integer entries are not expected.
  • gcd(a, 0) = a: By convention, the greatest common factor of any number and zero is the number itself, which keeps the fold well-defined when zeros appear.

Report a bug

This field is required.