Audited 05 Aug 2026·Last updated 28 Oct 2026·3 citations·Tier 2·0 uses

Common Factor Calculator

Find the greatest common factor of two positive whole numbers by Euclid's algorithm, then use it to simplify a fraction or get the least common multiple.

Common Factor Calculator

Greatest common factor
42
The largest whole number that divides both of your integers exactly; 1 if they share no other factor.

Background.

Two numbers share a common factor when both can be divided by it with nothing left over, and the largest of those shared divisors is the one most practical questions need. It is the number that cuts 84/126 down to 2/3 in a single step. It is the largest number of identical packs you can make from 84 red tiles and 126 blue ones with no tile left over. Divide it into the product of the two numbers and you get their least common multiple, the figure behind common denominators and repeating schedules.

School usually teaches two ways to find it: list every factor of both numbers and pick the largest one they share, or break each number into primes and multiply the primes they have in common. Both work for small numbers and both become painful quickly; factoring a fifteen-digit number by hand is not realistic.

This page uses the method Euclid set down more than two thousand years ago, which needs no factoring at all. Divide the larger number by the smaller and keep only the remainder. Then divide the previous divisor by that remainder, and repeat. The remainders shrink every time, and the last divisor before a remainder of zero is the greatest common factor. It works because anything that divides both numbers must also divide their difference, and so their remainder, which lets the pair be swapped for a smaller pair with exactly the same common factors.

The method stays quick even for huge inputs, since the number of division steps never exceeds five times the number of digits in the smaller number. Enter two positive whole numbers up to 9,000,000,000,000,000; decimals, zero and negatives are refused, and three or more numbers are handled two at a time.

What is common factor calculator?

The greatest common factor (GCF) of two positive integers, also called the greatest common divisor or highest common factor, is the largest whole number that divides both of them exactly. Every other common factor of the pair is itself a factor of the GCF: the common factors of 84 and 126 are 1, 2, 3, 6, 7, 14, 21 and 42, all of them divisors of 42. When the GCF is 1 the two numbers are called coprime, or relatively prime, even if neither is a prime number.

How to use this calculator.

  1. Enter the First positive integer and the Second positive integer in either order; swapping them gives the same answer.
  2. Use whole numbers only. For decimals such as 1.2 and 1.8, multiply both by the same power of ten to get 12 and 18, find their GCF of 6, then divide back to 0.6.
  3. For three or more numbers, find the GCF of the first two, enter that result with the third number, and carry on down the list.
  4. Read the greatest common factor. Divide a fraction's top and bottom by it to put the fraction in lowest terms, or divide the product of the two numbers by it to get their least common multiple.

The formula.

Euclidean algorithm: gcd(a,b)=gcd(b,a mod b)

gcd(a, b) = gcd(b, a mod b), repeated until the second number is zero, at which point the first number is the answer. Here a mod b is the remainder left when a is divided by b. The rule holds because any number dividing both a and b also divides a − b, a − 2b and so on, and therefore divides the remainder; in the other direction, anything dividing b and the remainder also divides a. The pair (b, a mod b) therefore has exactly the same common factors as (a, b) but is smaller, and since the remainders keep shrinking, the process must reach zero. If a starts out smaller than b, the first step simply swaps them, because a mod b is then a itself. The arithmetic is exact integer division with nothing to round. Input size barely affects the work: the number of steps grows with the number of digits, not with the size of the numbers.

A worked example.

Example

Take 84 and 126. The first division is 126 ÷ 84, which goes once with 42 left over: 126 = 1 × 84 + 42. Now divide the old divisor by that remainder: 84 = 2 × 42 + 0. The remainder is zero, so the last divisor, 42, is the greatest common factor. Prime factors confirm it. 84 = 2² × 3 × 7 and 126 = 2 × 3² × 7; the primes they share, 2 × 3 × 7, multiply to 42. With that number, 84/126 reduces to 2/3 at once, the least common multiple is 84 × 126 ÷ 42 = 252, and 84 red and 126 blue tiles split into 42 identical packs of 2 red and 3 blue.

integer A84
integer B126

Frequently asked questions.

How do I get the least common multiple from the greatest common factor?
Multiply the two numbers and divide by their GCF. For 84 and 126 that is 84 × 126 ÷ 42 = 252. Dividing one number by the GCF before multiplying keeps the figures small: 84 ÷ 42 = 2, and 2 × 126 = 252. For coprime numbers the least common multiple is simply their product.
What does it mean when the answer is 1?
The two numbers are coprime: they share no factor except 1. Neither has to be prime for that to happen. 35 is 5 × 7 and 64 is 2 to the sixth power, so their GCF is 1, the fraction 35/64 is already in lowest terms, and their least common multiple is 35 × 64 = 2,240.
How do I find the greatest common factor of three numbers?
Work in pairs. The GCF of 84, 126 and 105 is the GCF of 42 and 105, because 42 already carries every factor 84 and 126 share. Euclid's steps give 105 = 2 × 42 + 21 and 42 = 2 × 21 + 0, so the answer is 21.
Why not just list all the factors and compare?
For numbers like 84 and 126 listing works fine. For large numbers it means factoring, which grows impractical fast, while Euclid's method only ever divides and keeps remainders. Two sixteen-digit numbers need at most 80 division steps, a bound proved by Gabriel Lamé in the nineteenth century.
Why are zero and negative numbers not accepted?
Every whole number divides zero, so by convention the GCF of a number and zero is the number itself, and there is nothing to work out. Negative numbers have the same factors as their positive counterparts, so enter the absolute values; the page asks for positive integers from 1 upward.
Is the greatest common factor the same as the highest common factor?
Yes. Greatest common factor, greatest common divisor (GCD) and highest common factor (HCF) all name the same number. American textbooks tend to say GCF or GCD, while British and many Commonwealth syllabuses use HCF.

How this page was produced

Published by
Quanta Calculator
Primary sources
3 cited below
Method
Euclidean algorithm: gcd(a,b)=gcd(b,a mod b)
Published
Last verified

Built with AI assistance and verified by automated tests against the cited sources — every worked example on this page is computed by the same code that runs the calculator. How we build and check calculators.

In this category

Embed

Quanta Pro

Paid features are coming later.

  • All 1560 calculators remain free
  • No billing is enabled
Coming soon