Sub topic 11
Remainders of Sums, Differences, and Products
This chapter assumes you can write a division as n = dq + r with 0 ≤ r < d, and that you know the even and odd rules. It builds on both. By the end you should be able to find the remainder of an expression like 5n + 2 or a·b without knowing the actual numbers.
The working model
When you divide an integer by d, the remainder r is one of the d values 0, 1, ..., d − 1. Two integers a and b leave the same remainder on division by d exactly when d divides a − b. For example, 17 and 32 both leave remainder 2 on division by 5, and 32 − 17 = 15 is a multiple of 5.
The central fact is that you can replace each number by its remainder before you add, subtract, or multiply. The result has the same remainder as the original expression.
Here is why. Write a = dq₁ + r₁ and b = dq₂ + r₂. Then:
- a + b = d(q₁ + q₂) + (r₁ + r₂)
- a − b = d(q₁ − q₂) + (r₁ − r₂)
- ab = d(dq₁q₂ + q₁r₂ + q₂r₁) + r₁r₂
In each line, everything except the last bracket is a multiple of d. So the remainder of the whole expression equals the remainder of the last bracket. That bracket may fall outside 0 to d − 1, so you reduce it once more at the end.
| Expression | Remainder rule | Final step |
|---|---|---|
| a + b | r₁ + r₂ | Reduce if it is d or more |
| a − b | r₁ − r₂ | Add d if it is negative |
| a · b | r₁ · r₂ | Reduce if it is d or more |
| aᵏ | r₁ᵏ | Reduce, or look for a cycle |
Worked examples
Sum, difference, and product together
Let n leave remainder 4 and m leave remainder 5 when divided by 6.
- n + m: 4 + 5 = 9, and 9 leaves remainder 3.
- n · m: 4 · 5 = 20, and 20 leaves remainder 2.
- n − m: 4 − 5 = −1. Add 6 to get remainder 5.
Check with n = 10 and m = 11. The sum is 21, and 21 = 6·3 + 3. The product is 110, and 110 = 6·18 + 2. The difference is −1, and −1 = 6·(−1) + 5. All three match.
A product of large numbers
Find the remainder of 17 · 23 on division by 5. Since 17 leaves 2 and 23 leaves 3, the product leaves 2 · 3 = 6, which leaves 1. The code below confirms it.
print(divmod(47, 5)) # (9, 2), since 47 = 5*9 + 2
print(divmod(-7, 5)) # (-2, 3), since -7 = 5*(-2) + 3
print((17 * 23) % 5) # 1
print(((17 % 5) * (23 % 5)) % 5) # 1A linear expression
When n leaves remainder 3 on division by 8, find the remainder of 5n + 2. Multiply and add the remainder: 5 · 3 + 2 = 17, and 17 leaves 1. Testing n = 3 gives 17, which leaves 1. Testing n = 11 gives 57, and 57 = 8·7 + 1.
A power
Find the remainder of 2¹⁰ on division by 7. Since 2³ = 8 leaves remainder 1, every factor of 2³ can be replaced by 1. Then 2¹⁰ = (2³)³ · 2 leaves 1³ · 2 = 2. Direct computation agrees: 1024 = 7·146 + 2.
This works for any base whose power reaches remainder 1. After that, the remainders repeat in a cycle. The next chapters use the same idea for units digits, where the divisor is 10.
Checking the rules by brute force
You can test the three rules on many pairs at once. Python's % operator returns a result between 0 and d − 1 whenever d is positive, which matches the GRE convention.
ok = True
for d in range(2, 13):
for a in range(-30, 31):
for b in range(-30, 31):
if (a + b) % d != ((a % d) + (b % d)) % d:
ok = False
if (a - b) % d != ((a % d) - (b % d)) % d:
ok = False
if (a * b) % d != ((a % d) * (b % d)) % d:
ok = False
print(ok) # TrueCommon errors
Leaving a remainder that is too large
A remainder must be smaller than the divisor. If you add remainders 4 and 5 for divisor 6 and report 9, you have not finished. Reduce it to 3.
Forgetting to fix negative results
For subtraction, r₁ − r₂ can be negative. Add d once, or as many times as needed, until the value is between 0 and d − 1. Remainders 1 and 6 with divisor 7 give 1 − 6 = −5, and −5 + 7 = 2.
Trying to divide remainders
The rules cover addition, subtraction, multiplication, and powers. They do not cover division. If n leaves remainder 2 on division by 6, you cannot say what n/2 leaves. If you try n = 8 and n = 14, then n/2 gives 4 and 7. The first leaves 4 on division by 6 and the second leaves 1.
Cancelling a common factor fails in the same way. We have 2 · 1 and 2 · 4 leaving the same remainder on division by 6, since 2 and 8 both leave 2. But 1 and 4 do not leave the same remainder.
Changing the divisor
You can move to a smaller divisor that divides the original one. If n leaves 4 on division by 6, then n leaves 1 on division by 3, because 3 divides 6. Check n = 4, 10, 16: the remainders on division by 3 are 1, 1, 1.
You cannot move to a larger divisor. The values n = 4, 10, 16, 22 all leave 4 on division by 6, yet on division by 12 they leave 4, 10, 4, 10. The answer is not determined.
Treating a remainder of 0 as "no information"
A remainder of 0 means the number is a multiple of d. It is the most useful case. If a leaves 0 on division by d, then ab leaves 0 for every integer b.
Applying it in a quantity comparison
When integer n is divided by 7, the remainder is 5.
- Quantity A: the remainder when 3n is divided by 7
- Quantity B: 2
Compute 3 · 5 = 15, and 15 leaves 1 on division by 7. So Quantity A is 1, which is less than 2. Quantity B is greater. Test n = 12 as a check: 36 = 7·5 + 1.
For a problem where the remainder is not fixed, list the possible remainders and test each. If n is odd and you want the remainder of n² on division by 4, then n leaves 1 or 3. Both give n² remainder 1, since 1² = 1 and 3² = 9 leaves 1.
Exercise
When x is divided by 9 the remainder is 7, and when y is divided by 9 the remainder is 8. What is the remainder when x + y is divided by 9? What is the remainder when x − y is divided by 9?
Show answer
For the sum, 7 + 8 = 15, and 15 leaves 6. For the difference, 7 − 8 = −1, and adding 9 gives 8. Check with x = 7 and y = 8: the sum is 15 = 9·1 + 6, and the difference is −1 = 9·(−1) + 8.
Exercise
When n is divided by 5 the remainder is 3. Quantity A is the remainder when n² + n is divided by 5. Quantity B is 2. Which quantity is greater, or are they equal, or is the relationship undetermined?
Show answer
Use remainder 3 for n. Then n² leaves 9, which reduces to 4, and adding n gives 4 + 3 = 7, which reduces to 2. The quantities are equal. Check with n = 8: 64 + 8 = 72 = 5·14 + 2.
Exercise
When n is divided by 10 the remainder is 6. Can you tell what the remainder is when n is divided by 4? Can you tell what it is when n is divided by 5?
Show answer
You cannot tell for 4, because 4 does not divide 10. The values n = 6 and n = 16 leave 2 and 0 on division by 4. You can tell for 5, because 5 divides 10, so n leaves 6 reduced by 5, which is 1. Check n = 6, 16, 26: the remainders on division by 5 are all 1.