GCF Calculator
Enter two to ten whole numbers and this GCF calculator returns their greatest common factor (also called the GCD or HCF), with the Euclidean algorithm steps shown.
Results
- Greatest common factor (GCF)
- -
- Least common multiple (LCM)
- -
Steps (Euclidean algorithm)
How to use the GCF calculator
- Type two to ten positive whole numbers, separated by commas, spaces or line breaks.
- The greatest common factor appears at once. The least common multiple is shown too, because the two are closely linked.
- Open the steps underneath to see each division of the Euclidean algorithm.
- Use Copy results to keep the answer, or Reset to start over.
What the greatest common factor is
The greatest common factor of a set of whole numbers is the largest whole number that divides all of them with nothing left over. Different textbooks call the same thing the greatest common divisor (GCD) or the highest common factor (HCF). It is used to simplify fractions, to split things into equal groups and to reduce ratios to lowest terms.
Method: the Euclidean algorithm
Euclid described this method in Book VII of the Elements. Divide the larger number by the smaller one and keep the remainder. Then divide the smaller number by the remainder, and keep going until the remainder is zero. The last non-zero remainder is the GCF. It is much faster than listing all the factors, and it stays quick for numbers with dozens of digits. For more than two numbers, find the GCF of the first two, then the GCF of that result with the next number, and so on.
GCF(a, b) = GCF(b, a mod b), and GCF(a, 0) = a
Worked example 1: GCF of 48 and 18
48 = 2 × 18 + 12. Then 18 = 1 × 12 + 6. Then 12 = 2 × 6 + 0. The last non-zero remainder is 6, so GCF(48, 18) = 6. Check: 48 ÷ 6 = 8 and 18 ÷ 6 = 3, both whole numbers, and 8 and 3 share no further factor.
Worked example 2: GCF of 1071 and 462
1071 = 2 × 462 + 147. Then 462 = 3 × 147 + 21. Then 147 = 7 × 21 + 0. The GCF is 21. This pair is the standard example in many references on the Euclidean algorithm.
Worked example 3: GCF of 12, 18 and 30
First GCF(12, 18) = 6. Then GCF(6, 30) = 6, because 30 = 5 × 6 + 0. So the GCF of all three numbers is 6. Using it to simplify, 12 : 18 : 30 reduces to 2 : 3 : 5.
GCF and LCM
For two numbers, GCF × LCM = a × b, so once you know the GCF you can get the LCM by dividing the product by it. The calculator uses that fact to display the LCM. If you want to see the prime factorization method for the LCM, use the LCM calculator.
Limits
The tool accepts 2 to 10 positive whole numbers of up to 30 digits each and uses exact big-integer arithmetic, so results stay correct above 9,007,199,254,740,991, the largest integer that ordinary JavaScript numbers can hold without rounding. Zero, negative numbers and decimals are rejected with a message so you can correct them.
Frequently asked questions
What is the greatest common factor?
The greatest common factor (GCF) of a set of whole numbers is the largest whole number that divides every one of them with no remainder. For 12, 18 and 30 it is 6. It is also called the greatest common divisor (GCD) or highest common factor (HCF).
How does the Euclidean algorithm find the GCF?
Divide the larger number by the smaller one and keep the remainder. Then divide the smaller number by that remainder, and repeat until the remainder is 0. The last non-zero remainder is the GCF. For 48 and 18: 48 = 2 x 18 + 12, 18 = 1 x 12 + 6, 12 = 2 x 6 + 0, so the GCF is 6.
How is the GCF of more than two numbers found?
Find the GCF of the first two numbers, then find the GCF of that answer and the third number, and continue through the list. This works because GCF(a, b, c) = GCF(GCF(a, b), c). The calculator shows the steps for each stage.
What does it mean if the GCF is 1?
Numbers whose GCF is 1 are called relatively prime or coprime. They share no factor other than 1. For example 8 and 15 are coprime even though neither of them is a prime number.
How are the GCF and LCM related?
For two numbers a and b, GCF(a, b) x LCM(a, b) = a x b. This calculator also shows the least common multiple. For a dedicated tool with prime factorization steps, see the LCM calculator.