Sub topic 8
Using a^n ± b^n factors and the remainder theorem
This chapter assumes you can already use congruence notation, reduce remainders of sums and products, and use negative remainders such as 10 ≡ −1 (mod 11). It adds two tools that give exact divisibility facts about powers without finding cycles: the factor rules for a^n ± b^n, and the polynomial remainder theorem.
The factor rules for a^n ± b^n
The identity behind most of these results is:
a^n − b^n = (a − b)(a^(n−1) + a^(n−2)b + … + b^(n−1))
The second factor is an integer for any integers a and b, so a − b always divides a^n − b^n. In congruence terms, a ≡ b (mod a − b), so a^n ≡ b^n (mod a − b).
Substituting −b for b gives the rules for a + b. The sign of (−b)^n depends on whether n is odd or even.
| Expression | Divisible by a − b? | Divisible by a + b? |
|---|---|---|
| a^n − b^n, any n | Yes | Only if n is even |
| a^n + b^n, n odd | No (in general) | Yes |
| a^n + b^n, n even | No (in general) | No (in general) |
For even n, a^n + b^n leaves remainder 2b^n when divided by a + b. This follows because a ≡ −b, so a^n ≡ b^n, and the sum is 2b^n.
A second family of rules covers composite exponents. If m divides n, then a^m − b^m divides a^n − b^n. For example, 2^12 − 1 is divisible by 2^6 − 1, 2^4 − 1, 2^3 − 1 and 2^2 − 1, which are 63, 15, 7 and 3.
Worked examples with the factor rules
Example 1: remainder of 10^100 + 1 divided by 11. Here a = 10, b = 1 and n = 100 is even. So 10^100 − 1 is divisible by 10 + 1 = 11. Then 10^100 + 1 = (10^100 − 1) + 2, and the remainder is 2.
Example 2: remainder of 5^99 + 6^99 divided by 11. The exponent 99 is odd and 5 + 6 = 11, so the sum is divisible by 11. The remainder is 0.
Example 3: remainder of 5^100 + 6^100 divided by 11. The exponent is even, so use 6 ≡ −5 (mod 11). Then 6^100 ≡ 5^100, and the sum is ≡ 2 · 5^100. Since 5^5 = 3125 = 11 · 284 + 1, we get 5^5 ≡ 1, so 5^100 = (5^5)^20 ≡ 1. The remainder is 2.
Example 4: remainder of 3^100 + 5^100 divided by 8. The exponent is even, so the factor rule gives no zero remainder. Use the squares instead: 3² = 9 ≡ 1 and 5² = 25 ≡ 1 (mod 8). Both powers are ≡ 1, so the sum is ≡ 2.
Example 5: remainder of 1^n + 2^n + 3^n + 4^n divided by 5. This is a classic CAT pattern. Pair the terms as 1 and 4, and 2 and 3. Each pair sums to 5. For odd n, a^n + b^n is divisible by 5 for each pair, so the remainder is 0. For n = 100, use 2⁴ = 16 ≡ 1, 3⁴ = 81 ≡ 1 and 4² = 16 ≡ 1. All four terms are ≡ 1, so the remainder is 4.
The same logic works for n a multiple of 4. For n ≡ 2 (mod 4), the terms 2^n and 3^n are ≡ −1, so the remainder is 1 − 1 − 1 + 1 = 0. This is why such questions often hide a condition on n.
You can confirm all five results in Python:
print((10**100 + 1) % 11) # 2
print((5**99 + 6**99) % 11) # 0
print((5**100 + 6**100) % 11) # 2
print((3**100 + 5**100) % 8) # 2
print(sum(pow(k, 100, 5) for k in range(1, 5)) % 5) # 4
print(sum(pow(k, 99, 5) for k in range(1, 5)) % 5) # 0The polynomial remainder theorem
A polynomial f(x) is an expression such as x³ − 2x² + 5x − 7. When you divide f(x) by a linear divisor x − c, you get a quotient polynomial q(x) and a constant remainder r:
f(x) = (x − c) · q(x) + r
Put x = c. The term (x − c) · q(x) becomes 0, so r = f(c). This is the remainder theorem: the remainder of f(x) divided by x − c is f(c).
For a divisor x + c, rewrite it as x − (−c). The remainder is f(−c).
Take f(x) = x³ − 2x² + 5x − 7.
- Divided by x − 2, the remainder is f(2) = 8 − 8 + 10 − 7 = 3.
- Divided by x + 1, the remainder is f(−1) = −1 − 2 − 5 − 7 = −15.
The second remainder is negative, and that is fine here. A polynomial remainder only has to have lower degree than the divisor, so a constant of any sign is allowed. Do not add anything to it.
The function below evaluates f(c) using Horner's method, which is the same as synthetic division. It reads the coefficients from the highest power down.
def poly_remainder(coeffs, c):
"""Remainder of f(x) divided by (x - c). coeffs go from highest power down."""
r = 0
for k in coeffs:
r = r * c + k
return r
f = [1, -2, 5, -7] # x^3 - 2x^2 + 5x - 7
print(poly_remainder(f, 2)) # 3
print(poly_remainder(f, -1)) # -15The remainder theorem also gives the factor theorem. If f(c) = 0, then x − c is a factor of f(x). For example, x^n − 1 has f(1) = 0, which is the polynomial form of "a − b divides a^n − b^n" with b = 1.
Divisors of higher degree
If the divisor has degree 2, the remainder has degree at most 1, so write it as ax + b. Find the roots of the divisor, substitute each into f, and solve for a and b.
Example: remainder of x^100 divided by x² − 1. The roots are 1 and −1. Write the remainder as ax + b.
- At x = 1: a + b = 1.
- At x = −1: −a + b = 1.
Adding the equations gives b = 1, and then a = 0. The remainder is 1.
Example: remainder of x^99 divided by x² − 1. At x = 1: a + b = 1. At x = −1: −a + b = −1. Adding the equations gives b = 0, and then a = 1. The remainder is x.
This method needs the divisor to factor into distinct roots. For a repeated root, such as (x − 1)², you also need the derivative, which is beyond what CAT asks.
Connecting the polynomial view to numbers
Numbers behave like a polynomial evaluated at a base. If N = f(10) with digits as coefficients, then dividing N by 9 gives the same remainder as f(1), the digit sum. Dividing by 11 uses f(−1), the alternating digit sum. Those are the divisibility tests from the earlier chapter, now seen as the remainder theorem with c = 1 and c = −1.
You can use the same idea to rewrite a base close to the divisor. To find 17^200 mod 18, note 17 = 18 − 1, so 17^200 ≡ (−1)^200 = 1. To find 8^n mod 7, note 8 = 7 + 1, so the remainder is always 1.
Common errors
- Wrong parity. a^n + b^n is divisible by a + b only for odd n.
- Wrong divisor type. The remainder theorem works directly for divisors of the form x − c. For a divisor such as 2x − 3, use c = 3/2, and remember the quotient then has fractional coefficients.
- Remainder degree. The remainder must have lower degree than the divisor. A constant is correct for a linear divisor, and a linear expression for a quadratic divisor.
- Forgetting to add back. After showing a^n − b^n is divisible, the original expression may differ from it by 2b^n or by a constant. Add that difference to the remainder before you finish.
- Negative numeric results. If a numeric remainder comes out negative, add the modulus once to bring it into 0 to n − 1.
Exercise
Find the remainder when 13^100 + 17^100 is divided by 30.
Show answer
The exponent is even, and 13 + 17 = 30, so 17 ≡ −13 (mod 30) and the sum is ≡ 2 · 13^100. Since 13^4 = 28561 = 30 · 952 + 1, we have 13^4 ≡ 1, so 13^100 = (13^4)^25 ≡ 1. The remainder is 2.
Exercise
Find the remainder when f(x) = x^100 − 2x^50 + x + 3 is divided by x + 1.
Show answer
By the remainder theorem the remainder is f(−1) = 1 − 2 − 1 + 3 = 1.
Exercise
Is 8^n − 2^n divisible by 6 for every positive integer n? Is 8^n + 2^n divisible by 10 for every positive integer n?
Show answer
The first is always true because 8 − 2 = 6 divides 8^n − 2^n. The second is false in general. The sum is divisible by 8 + 2 = 10 only for odd n. For n = 2, 64 + 4 = 68, which leaves remainder 8 on division by 10.