StringMash.com

GCF calculator

The greatest common factor of two or more numbers, with every step shown.

6 characters
Updates as you type
GCF12
LCM144
The working and Venn diagram are below

Show the steps
4836222233
  1. Split each number into primes:
  2. 48 = 2⁴ × 3
  3. 36 = 2² × 3²
  4. Take the primes they all share, each to the lowest power it has in any of them: 2² × 3 = 12.
  5. Check with Euclid's method: divide, then divide the last divisor by the remainder until it comes out exact.
  6. 48 = 1 × 36 + 12
  7. 36 = 3 × 12 + 0
  8. The last divisor, 12, is the GCF.

Using the calculator

Type two or more whole numbers, separated by commas or spaces, such as 48, 36 or 24 36 60. The greatest common factor appears straight away, with the working below and the least common multiple beside it. Up to 10 numbers work, each up to a trillion.

For two numbers the working shows both ways of finding it, the prime factors, sorted in a Venn diagram, and Euclid's method of repeated division as a check. They always agree.

What the greatest common factor is

A factor of a number divides it exactly. The factors of 12 are 1, 2, 3, 4, 6 and 12; the factors of 18 are 1, 2, 3, 6, 9 and 18. The ones they have in common are 1, 2, 3 and 6, and the greatest of those, 6, is the greatest common factor. It's also called the highest common factor (HCF), mostly in the UK, and the greatest common divisor (GCD) by mathematicians and programmers. All three are the same number.

Simplifying a fraction is the usual use. Divide the top and bottom of 36/48 by their GCF, 12, and you get 3/4 in one step, already in lowest terms. It also answers sharing problems: the largest equal groups that 48 pencils and 36 rubbers can both be split into, with none left over, is 12 groups.

Finding it with prime factors

Write each number as a product of primes, so 48 = 2⁴ × 3 and 36 = 2² × 3². Then take the primes they share, each to the lowest power it has in any of them. Both have 2, at least twice, and 3, at least once, so the GCF is 2² × 3 = 12.

The Venn diagram shows the same thing. Each number's primes go in its circle, and primes the two share go in the overlap. Multiply the overlap for the GCF. Multiply everything in both circles for the least common multiple. If the overlap is empty the GCF is 1, and the numbers are called coprime.

Euclid's method

For big numbers, factoring is slow, and Euclid's method from around 300 BC is much faster. Divide the larger number by the smaller and keep the remainder, so 48 = 1 × 36 + 12. Then divide the smaller number by that remainder, giving 36 = 3 × 12 + 0. When the remainder is 0, the last number you divided by, 12, is the GCF.

It works because any number that divides both 48 and 36 also divides their difference, and so the remainder. The pair shrinks at every step but keeps the same common factors, until one divides the other exactly.

Questions

Is the GCF the same as the HCF and the GCD?

Yes. Greatest common factor, highest common factor and greatest common divisor are three names for the same number.

What is the GCF of two prime numbers?

1, unless they're the same prime. Primes have no factors but 1 and themselves, so two different primes share only 1.

Can the GCF be one of the numbers?

Yes, when it divides all the others. The GCF of 6 and 18 is 6.

What about 0 or negative numbers?

Every number divides 0, so 0 has no greatest factor and the calculator asks for numbers of 1 or more. For negative numbers, leave off the signs, since the GCF is the same.

How is the GCF related to the LCM?

For two numbers, the GCF times the LCM equals the two numbers multiplied together. For 12 and 18, 6 × 36 = 216 = 12 × 18.

Sources

Added and reviewed . What's new