Math

GCF Calculator

Find the greatest common factor of two numbers instantly.

Find the greatest common factor (GCF, also called GCD) of two numbers — the largest number that divides both evenly. Used for simplifying fractions and ratios, factoring expressions, and splitting quantities into equal groups.

How it's calculated

The GCF is found with the Euclidean algorithm: repeatedly replace the larger number with the remainder of dividing it by the smaller until the remainder is zero — the last non-zero remainder is the GCF.

A factor of a number is a whole number that divides it exactly, with no remainder. The greatest common factor of two numbers is the largest number that appears in both of their factor lists. This calculator takes the two whole numbers you enter as its only inputs — if you type a negative number it is treated as its positive value, since factors are about size, not sign — and it returns that single shared divisor.

The Euclidean algorithm works because any number that divides both of the original numbers must also divide their remainder. So instead of listing every factor, the method swaps the problem for a smaller one with the same answer: divide, keep the remainder, and repeat with the divisor and remainder. The remainders shrink at every step, so the process always ends, and the last non-zero remainder divides both starting numbers while nothing larger can. That is why the method stays fast even for numbers with many digits, where writing out full factor lists would be hopeless.

Worked example

Find the GCF of 48 and 180. Start by dividing the larger number by the smaller: 180 = 3 × 48 + 36, so the remainder is 36. Now divide 48 by that remainder: 48 = 1 × 36 + 12, leaving 12. Divide once more: 36 = 3 × 12 + 0. The remainder has reached zero, so the last non-zero remainder, 12, is the greatest common factor. You can check it directly: 48 ÷ 12 = 4 and 180 ÷ 12 = 15, and 4 and 15 share no factor larger than 1, which confirms that nothing bigger than 12 divides both numbers.

When to use it

The most common job for the GCF is simplifying fractions and ratios: dividing 48/180 by 12 gives 4/15 in one step, with no repeated rounds of cancelling. It also answers sharing problems — if you have 48 of one item and 180 of another and want the largest possible equal groups with nothing left over, the GCF tells you there can be 12 groups. The same idea sizes tiles: the largest square tile that covers a rectangular floor with no cutting has a side length equal to the GCF of the floor's length and width.

Common mistakes

  • Confusing the GCF with the LCM. The GCF is the largest number that divides both of your numbers; the LCM is the smallest number that both of your numbers divide into — they answer opposite questions.
  • Stopping at the first common factor you spot. 48 and 180 are both even, but their GCF is 12, not 2 — a shared factor is not necessarily the greatest one.
  • Assuming the answer must be small. Closely related numbers can share a large factor: the GCF of 96 and 144 is 48.
  • Trying to list all the factors of very large numbers by hand and missing one, which is exactly the error the remainder method avoids.

Frequently asked questions

What is the GCF of 12 and 18?

6. It's the largest number that divides both 12 and 18 evenly.

What is the difference between GCF and GCD?

Nothing — GCF (greatest common factor) and GCD (greatest common divisor) are two names for the same thing.

How is the GCF used to simplify fractions?

Divide the numerator and denominator by their GCF. For 12/18, the GCF is 6, so 12/18 simplifies to 2/3.

Can I enter negative numbers?

Yes. The calculator treats a negative number as its positive value, because the greatest common factor is about divisibility and size. The GCF of -48 and 180 is the same as the GCF of 48 and 180, which is 12.

What if the two numbers share no factor except 1?

Then the GCF is 1 and the numbers are called coprime, or relatively prime. For example, 8 and 15 share no divisor larger than 1, so a fraction like 8/15 is already in lowest terms.

Does the order of the two numbers matter?

No. The GCF of 48 and 180 is the same as the GCF of 180 and 48 — the Euclidean algorithm simply starts with whichever number is larger, and both orders end at 12.

GCF in more depth

A second worked example: 84 and 126

Enter 84 as the first number and 126 as the second. The Euclidean algorithm starts with the larger number: 126 = 1 × 84 + 42, so the first remainder is 42. The next step divides 84 by that remainder: 84 = 2 × 42 + 0. Because the remainder has reached zero in just two steps, the last non-zero remainder, 42, is the greatest common factor. You can confirm it without the algorithm: 84 ÷ 42 = 2 and 126 ÷ 42 = 3, and since 2 and 3 share no factor larger than 1, no number bigger than 42 can divide both starting numbers. Notice how much larger this GCF is than the pair in the first worked example — 42 against 12 — even though the starting numbers are of a similar size. The size of the answer depends on how the two numbers are related, not on how big they are.

Where the two inputs come from in real problems

The two numbers you type are usually measurements or counts that have to fit together exactly. A caterer with 84 sandwiches and 126 drinks who wants identical hampers with nothing left over needs the GCF of the sandwich count and the drink count: 42 hampers, each holding 2 sandwiches and 3 drinks. A rectangular rug 84 cm wide and 126 cm long raises the same question in centimetres: the largest square patch that tiles it with no cutting has sides of 42 cm, giving a grid 2 patches by 3 patches. In a classroom, 84 and 126 might be the numbers of students in two year groups who must be split into mixed teams of exactly equal size — 42 teams is the largest arrangement that uses everyone. In each case the practical question is identical: what is the biggest unit that measures both quantities a whole number of times?

Edge cases in this calculator

A few inputs behave in ways worth knowing before you rely on the result. If the two numbers are equal, the GCF is that number itself: enter 54 and 54 and the answer is 54, because 54 divides 54. If one of the numbers is 0, the GCF is the other number — the GCF of 0 and 18 is 18, since every factor of 18 divides 0. Only entering 0 twice leaves nothing to report, because zero has no greatest factor. The calculator also rounds anything you type to the nearest whole number and ignores its sign before it starts, so entering 84.4 or −84 gives the same result as entering 84. That rounding is harmless for the whole-number counts and lengths this tool is built for, but it means decimal measurements should be converted to a shared whole-number unit, such as millimetres instead of centimetres, before you enter them.

Checking a GCF answer with the LCM

For any two numbers, the GCF and the least common multiple are linked by a simple identity: GCF × LCM = first number × second number. That gives you an independent way to check a result from this page. For 84 and 126, the product of the two inputs is 84 × 126 = 10,584. Dividing that product by the GCF gives 10,584 ÷ 42 = 252, which is the LCM of 84 and 126 — and you can confirm it directly, because 252 ÷ 84 = 3 and 252 ÷ 126 = 2, so 252 really is a multiple of both, and the identity guarantees it is the smallest one. If you run the companion LCM Calculator on the same pair and the two answers do not multiply back to 10,584, one of the entries was typed differently, which makes this a quick consistency check when a simplified fraction or a grouping answer depends on getting the GCF exactly right.

Related calculators