Modular arithmetic
17 ≡ 2 (mod 5)
The idea
“Clock” arithmetic: you only look at the remainder.The board
- 17 ≡ 2 (mod 5), because 17 and 2 leave the same remainder when divided by 5.
- A clock is mod 12: 10 o'clock + 5 hours = 3 o'clock.
- You can add and multiply and take the remainder at the end — or along the way.
- All of internet cryptography (HTTPS, banks) rests on this.
The most common mistake
Dividing freely. Division mod n only works sometimes (when the number is coprime to the modulus).The trick
The last digit of a number is the number mod 10. What's the last digit of 7100? The cycle 7, 9, 3, 1 → 1.Problems
23 mod 7 = ?
- 2
- 7
- 3
- 16
Show the answer
2 — 23 = 3 · 7 + 2.
It's 9 o'clock now. What time in 50 hours?
- 11 o'clock
- 9 o'clock
- 59 o'clock
- 7 o'clock
Show the answer
11 o'clock — 50 mod 24 = 2 → 9 + 2.