Sub topic 8
Highest Common Factor
Prerequisites and meaning
Assume you can multiply, divide with remainders, use prime factorization, and work with powers. A factor of a number divides it exactly. The highest common factor (HCF) of two or more numbers is the greatest positive integer that is a factor of every number. It is also called the greatest common divisor (GCD).
For example, the common factors of 18 and 30 are 1, 2, 3, and 6. Therefore:
\[ \operatorname{HCF}(18,30)=6 \]
The HCF is useful when a problem asks for the largest equal size, the greatest possible length, or the largest number of identical groups.
Finding the HCF by prime factorization
Write each number as a product of prime powers. The HCF contains only the primes common to all numbers, using the smallest exponent of each common prime.
For example:
\[ 84=2^2 \times 3 \times 7 \]
\[ 126=2 \times 3^2 \times 7 \]
The common primes are 2, 3, and 7. Select the smaller exponent for each:
\[ \operatorname{HCF}(84,126)=2^1 \times 3^1 \times 7=42 \]
| Prime | Power in 84 | Power in 126 | Power used in HCF |
|---|---|---|---|
| 2 | 2 | 1 | 1 |
| 3 | 1 | 2 | 1 |
| 7 | 1 | 1 | 1 |
This method is reliable when the numbers are small enough to factor quickly or when their prime forms are already given.
Euclid's algorithm
For larger numbers, Euclid's algorithm is usually faster. It uses the fact that:
\[ \operatorname{HCF}(a,b)=\operatorname{HCF}(b,a\bmod b) \]
Here, \(a\bmod b\) means the remainder after dividing \(a\) by \(b\). Continue replacing the pair with the smaller number and the remainder. The last non-zero remainder is the HCF.
For 252 and 105:
\[ 252=2(105)+42 \]
\[ 105=2(42)+21 \]
\[ 42=2(21)+0 \]
Therefore, the HCF is 21.
def gcd(a, b):
while b:
a, b = b, a % b
return a
print(gcd(252, 105)) # 21Choosing the correct method
| Situation | Useful method |
|---|---|
| Numbers have simple prime factors | Prime factorization |
| Numbers are large | Euclid's algorithm |
| A word problem asks for the largest equal size | HCF |
A common error is selecting the largest prime exponent instead of the smallest one. The HCF must divide each original number, so every selected exponent must be no larger than the exponent in any input number.
Exercise
Find the HCF of 360 and 504 using prime factorization.
Show answer
360 = 2^3 × 3^2 × 5 and 504 = 2^3 × 3^2 × 7. Use the smallest common exponents: HCF = 2^3 × 3^2 = 72.