HCF Calculator

Enter two to ten whole numbers to find their highest common factor by the division method, one line at a time.

Inputs

The numbers

Two to ten numbers, separated by commas or spaces. Example: 252, 105.

Try an example

Highest common factor

21

The largest number that divides both 252 and 105 with no remainder.

Least common multiple
1,260
Division steps
3
Fraction in lowest terms
12/5
Ratio in lowest terms
12 : 5

Step-by-step solution

  1. Divide the larger number by the smaller and note the remainder. Then divide the divisor by that remainder, and keep going until the remainder is 0.

    252 = 2 × 105 + 42, 105 = 2 × 42 + 21, 42 = 2 × 21 + 0

  2. The divisor on the last line, where the remainder is 0, is the HCF of 252 and 105.

    HCF(252, 105) = 21

  3. Check with prime factors: break each number into primes.

    252 = 2² × 3² × 7, 105 = 3 × 5 × 7

  4. Multiply the primes that every number has, each to its lowest power.

    HCF = 3 × 7 = 3 × 7 = 21

  5. Check: for two numbers, the HCF times the LCM equals the product of the numbers.

    21 × 1,260 = 26,460 = 252 × 105

Formulas used

a = q × b + r one line of the division method

HCF(a, b) = HCF(b, r) why each line keeps the answer

HCF(a, 0) = a where the method stops

a, b
the larger and smaller number in the current line
q
the quotient, how many times b fits into a
r
the remainder, always smaller than b

The division method, also called Euclid's algorithm, is over two thousand years old and still the standard way to find an HCF by hand or by computer. Each line divides one number by another and keeps the remainder. That remainder becomes the next divisor, and the old divisor becomes the next dividend.

It works because a common factor of a and b must also divide the remainder r = a − q × b. Going the other way, a common factor of b and r divides a = q × b + r as well. So the two pairs share exactly the same common factors, and the HCF does not change from line to line. The remainders shrink every time, so the process must reach 0, and the divisor on that last line divides everything before it.

The method never needs the prime factors, which is why it stays fast for numbers that are far too large to factorise by hand. The calculator still shows a prime-factor check so you can confirm the result a second way.

Worked example: the HCF of 252 and 105

Numbers a = 252 and b = 105.

252 = 2 × 105 + 42

105 = 2 × 42 + 21

42 = 2 × 21 + 0

The last divisor is 21, so HCF = 21

Check: 252 = 2² × 3² × 7 and 105 = 3 × 5 × 7, so HCF = 3 × 7 = 21

A real use: you have a 252 cm ribbon and a 105 cm ribbon and want to cut both into equal pieces with none left over. The longest piece that works is the HCF, 21 cm, giving 12 pieces from the first and 5 from the second.

HCF of common pairs, with the number of division steps

The steps column counts the lines of the division method, up to and including the one with remainder 0. 1001 and 143 take a single line because 143 divides 1001 exactly.

NumbersHCFDivision stepsFraction in lowest terms
48, 18638/3
84, 361227/3
360, 15030312/5
252, 10521312/5
1001, 14314317
1071, 46221351/22
1260, 19818470/11
2024, 1012101212

The slowest case: consecutive Fibonacci numbers

Consecutive Fibonacci numbers are coprime and make the division method take as many lines as possible for their size, because every quotient except the last is 1. Even so, 987 and 610 need only 14 lines.

NumbersHCFDivision stepsFraction in lowest terms
8, 5148/5
13, 81513/8
34, 211734/21
89, 551989/55
233, 144111233/144
610, 377113610/377
987, 610114987/610

Frequently asked questions

What is the HCF, and is it the same as GCF and GCD?

The HCF is the highest common factor: the largest whole number that divides all of your numbers exactly. GCF (greatest common factor) and GCD (greatest common divisor) are the same value under other names. HCF is the usual term in the UK, India and Nepal, GCF in the US, and GCD in mathematics and computer science.

How does the division method work?

Divide the larger number by the smaller and keep the remainder. Then divide the smaller number by that remainder, and repeat with each new remainder until one is 0. The last divisor is the HCF. For 252 and 105: 252 = 2 × 105 + 42, 105 = 2 × 42 + 21, 42 = 2 × 21 + 0, so the HCF is 21.

Why does the division method give the right answer?

Any number that divides both a and b also divides the remainder r in a = q × b + r, because r = a − q × b. So a and b have exactly the same common factors as b and r. Each line replaces the pair with a smaller pair that has the same HCF, until the smaller number divides the other and is itself the answer.

Is the division method faster than listing factors?

Yes, by a wide margin. Listing factors means finding every factor of every number, and that gets impractical once the numbers have more than a few digits. The division method needs at most about five lines per digit of the smaller number (Lamé's theorem), so two 12-digit numbers need at most 60 lines, and typically far fewer. The worst case is two consecutive Fibonacci numbers, as the second table shows.

How do I find the HCF of three or more numbers?

Find the HCF of the first two, then find the HCF of that answer and the third number, and so on. HCF(a, b, c) = HCF(HCF(a, b), c). For 48, 72 and 120, HCF(48, 72) = 24 and HCF(24, 120) = 24, so the HCF is 24. The calculator shows each pair.

What does it mean when the HCF is 1?

The numbers are coprime, so they share no factor except 1. A fraction made from coprime numbers cannot be simplified, and their LCM equals their product. The division method always ends with a last divisor of 1 in this case, as for 987 and 610.

How do I use the HCF to simplify a fraction or ratio?

Divide both numbers by their HCF. For 252/105 the HCF is 21, so the fraction is 12/5. The calculator shows this in lowest terms for any two numbers. It also helps with standard-form line equations: dividing the coefficients of 6x + 9y = 12 by their HCF, 3, gives 2x + 3y = 4.

Can I use zero, negative numbers or decimals?

This calculator takes positive whole numbers of up to 12 digits. HCF(0, n) is just n and tells you nothing new. For negative numbers use the positive values. For decimals, multiply every number by the same power of 10 to make them whole, find the HCF, then divide the result by that power of 10.