Sub topic 3
Adding, Subtracting and Multiplying Remainders
Assume you know integer division, factors, and basic exponent rules. This chapter uses congruence notation. The statement a ≡ b (mod n) means that a and b leave the same remainder when divided by n. Equivalently, n divides a - b.
The working rule
Suppose:
a ≡ r (mod n)b ≡ s (mod n)
Then you may calculate with the smaller remainders:
a + b ≡ r + s (mod n)a - b ≡ r - s (mod n)a × b ≡ r × s (mod n)
After calculating, reduce the result to a standard remainder from 0 through n - 1.
For example, modulo 7:
47 ≡ 5 (mod 7)23 ≡ 2 (mod 7)
Therefore:
47 + 23 ≡ 5 + 2 ≡ 0 (mod 7)47 - 23 ≡ 5 - 2 ≡ 3 (mod 7)47 × 23 ≡ 5 × 2 ≡ 3 (mod 7)
The original numbers may be large, but the remainders are small.
| Operation | Reduce first | Then calculate |
|---|---|---|
| Addition | `47 → 5`, `23 → 2` | `5 + 2 = 7 → 0` |
| Subtraction | `47 → 5`, `23 → 2` | `5 - 2 = 3` |
| Multiplication | `47 → 5`, `23 → 2` | `5 × 2 = 10 → 3` |
A CAT-style expression
Find the remainder when 38 × 47 + 23 is divided by 7.
Reduce every number modulo 7:
38 ≡ 347 ≡ 523 ≡ 2
Now calculate:
38 × 47 + 23 ≡ 3 × 5 + 2 ≡ 17 ≡ 3 (mod 7)
The answer is 3.
This works because replacing a number with a congruent number does not change its remainder after addition, subtraction, or multiplication.
a, b, c, n = 38, 47, 23, 7
remainder = (a * b + c) % n
reduced_calculation = ((a % n) * (b % n) + c % n) % n
print(remainder) # 3
print(reduced_calculation) # 3Common errors
A negative intermediate result is allowed. For example:
5 - 12 ≡ -7 ≡ 0 (mod 7)
The standard remainder is 0, because -7 is divisible by 7.
Do not reduce across division. From a ≡ b (mod n), it is not generally valid to conclude a ÷ c ≡ b ÷ c (mod n). Division requires extra conditions and is a common source of incorrect CAT solutions.
Also, do not confuse a remainder with a congruence. The statement 47 ≡ 5 (mod 7) is true. The expression 47 % 7 gives the remainder 5.
A reliable process
- Identify the modulus.
- Replace each number with its remainder.
- Perform the required operations.
- Reduce the final value.
Exercise
Find the remainder when 124 × 39 - 18 is divided by 5.
Show answer
124 ≡ 4, 39 ≡ 4, and 18 ≡ 3 (mod 5). Thus 124 × 39 - 18 ≡ 4 × 4 - 3 = 13 ≡ 3 (mod 5). The remainder is 3.