What the greatest common factor is
The greatest common factor of a set of whole numbers is the largest whole number that divides every one of them without a remainder. It is also called the greatest common divisor (GCD), the highest common factor (HCF) and, in Euclid's wording, the greatest common measure. The names differ by country and textbook, but they describe the same number. For 12 and 18 the common factors are 1, 2, 3 and 6, so the greatest is 6.
Every common factor of a set of numbers also divides their GCF, which is why the GCF is the natural number to use when you want to split things as evenly as possible, simplify a fraction or find the biggest square that fits a rectangle. This calculator takes 2 to 10 positive whole numbers of up to 12 digits, shows the remainder steps for each pair and, for numbers up to 1,000,000, a prime factor table.
Equal-size groups: a worked example
Suppose you have 24 pencils, 36 erasers and 60 notebooks and want to pack identical kits with nothing left over. The number of kits has to divide all three quantities, so the most kits you can make is the GCF of 24, 36 and 60, which is 12. Each kit then holds 2 pencils, 3 erasers and 5 notebooks. Any smaller common factor also works, but it gives fewer, larger kits.
The same idea works for cutting rope into equal pieces, dividing a class into teams with the same mix of ages, or laying out planting rows. Whenever the question is "what is the largest equal share that fits every quantity exactly", the answer is a GCF.
Euclid's remainder method, step by step
The fast way to find the GCF of two numbers does not need their factors at all. Divide the larger number by the smaller one and keep the remainder. Then divide the smaller number by that remainder, and keep going until a division leaves no remainder. The last divisor is the GCF. Euclid described this procedure around 300 BC in Book VII of the Elements, where it is the method for finding the greatest common measure of two numbers.
Euclid's guide example uses 3009 and 884. 3,009 = 3 × 884 + 357; 884 = 2 × 357 + 170; 357 = 2 × 170 + 17; 170 = 10 × 17 + 0. The last nonzero remainder, and the divisor in the final row, is 17, so the GCF of 3009 and 884 is 17. The method is fast because the remainders shrink quickly: even for 12-digit numbers it needs only a few dozen divisions. The calculator above prints each of these rows in a table so you can check them against your own working.
The prime factor method
The classroom alternative is to write each number as a product of primes and keep what the numbers share. For 48 and 180 the prime factors are 2 × 2 × 2 × 2 × 3 and 2 × 2 × 3 × 3 × 5. The primes they have in common, each taken at its lowest power, are 2^2 × 3, which multiply to 12. This method is easy to see but slow for large numbers because factoring is much harder than dividing, so the calculator shows it only for numbers up to 1,000,000 and uses the remainder method for everything else.
More than two numbers
The GCF of three or more numbers is found one pair at a time: take the GCF of the first two, then the GCF of that result and the third number, and so on. For 12, 18 and 30 the first pair gives 6 and the second pair gives 6. The order of the numbers does not matter, and repeating a number changes nothing. Each pair gets its own table of remainder steps above, so a list of ten numbers shows nine short tables.
Simplifying fractions and ratios
To write a fraction in lowest terms, divide the numerator and the denominator by their GCF. For 18/48 the GCF is 6, so the fraction becomes 3/8. A ratio simplifies the same way: 18 : 48 is 3 : 8. If the GCF is 1, as it is for 35 and 64, the numbers are called coprime or relatively prime and the fraction is already in lowest terms (1 is the GCF of 35 and 64). To go the other way, adding fractions needs a common denominator, which is a job for the least common multiple calculator.
For two numbers there is a neat link between the two ideas: the GCF times the LCM equals the product of the numbers. For 12 and 18 that is 6 × 36 = 216, and 12 × 18 is also 216. The relationship holds for two numbers only, not for three or more.
Exact answers for big numbers
Ordinary spreadsheet and calculator arithmetic uses floating-point numbers that keep roughly 15 to 16 significant digits. JavaScript's largest safe integer is 9,007,199,254,740,991, and anything above it can be silently rounded. This calculator uses exact whole-number arithmetic, so the GCF of 999,999,999,989 and 999,999,999,979 is reported as 1 and their LCM, 999,999,999,968,000,000,000,231, is shown in full rather than in scientific notation.
Where the GCF shows up
Floors and walls: the largest square tile that covers a rectangular floor without cutting has a side equal to the GCF of the floor's length and width, measured in the same unit. After you know the tile size, the tile calculator counts boxes and waste, and the square footage calculator gives the area. Shared factors also matter when you scale a recipe or a ratio, and when you want to reduce a fraction before dividing; for that last step try the long division calculator.
Questions about the GCF
What is the GCF of two numbers?
It is the largest positive whole number that divides both without a remainder. The GCF of 12 and 18 is 6, and the GCF of 48 and 180 is 12.
How do I find the GCF of three or more numbers?
Find the GCF of two of them, then the GCF of that answer and the next number, and repeat. The calculator does this for up to 10 numbers and shows every pair.
Are GCF, GCD and HCF the same thing?
Yes. Greatest common factor, greatest common divisor and highest common factor are three names for the same number. Search results and textbooks use all three, so this page uses them interchangeably.
What is the GCF when two numbers share no factor?
It is 1. Such numbers are called coprime. For example, the GCF of 35 and 64 is 1, even though neither number is prime.
Why does the calculator reject zero, negatives and decimals?
The GCF is taught for positive whole numbers, and conventions for zero and negative numbers differ between books. To keep one clear definition the calculator accepts positive whole numbers only and names the entry it cannot use, so a typing slip is easy to find.
How large can the numbers be?
Each number can have up to 12 digits and you can enter 2 to 10 numbers. Larger inputs are refused instead of being rounded.
Source for the method: Euclid, Elements, Book VII, Proposition 2, in D. E. Joyce's online edition (Clark University), which also gives the 884 and 3009 example used above.