The Core Idea
Addition, subtraction, and multiplication all work the same way:
Do the operation, then take mod.
Addition
Clock intuition: 7 o’clock plus 8 hours lands on 3 o’clock.
Subtraction
Clock intuition: 3 o’clock minus 7 hours, go backwards to 8 o’clock.
What about negative results?
Mod always gives a result between and , where is the modulus. Negative numbers aren’t in that range.
The fix: add the modulus until positive.
Think about the clock. What’s ?
Go 1 step backwards from 0. You land on 11.
So . We get there by computing .
What about ?
Go 4 steps backwards from 0: .
So . Or just compute .
More examples:
| Expression | Calculation | Result |
|---|---|---|
| 4 | ||
| 3 | ||
| 2 |
If one addition isn’t enough, keep adding until you’re positive.
Multiplication
Same pattern: multiply, then take the remainder.
The Key Insight
Here’s something important:
Numbers with the same remainder are interchangeable.
What does this mean? Since , we can swap 17 for 5 in any mod 12 calculation.
They’re the same position on the clock. They behave identically.
The Shortcut
Since we can swap any number for its remainder, we can simplify before computing.
Take :
The hard way: , then
The easy way: and . Now .
Same answer. Much smaller numbers.
This works for addition too.
The hard way: , then
The easy way: and . Now , and .
Why This Matters
In cryptography, we compute things like:
If you computed first, you’d get a number with millions of digits.
Instead, take mod after each multiplication. The numbers stay small throughout, and you get the same answer.