Overview

Lets explore an example

modulus 5 → m = 5 which means that we only have the numbers [0,4] such that:

0 → 0, 1 → 1, 2 → 2, 3 → 3, 4 → 4, 5 → 0, 6 → 1, 7 → 2, 8 → 3, 9 → 4

what about negative u numbers?

-1 → 4, -2 → 3, -3 → 2, -4 → 1, -5 → 0

how? we’ll prove that later

Remainder Theorem

Let m be a positive integer, X be any integer, r be a number between 0 and m (0 inclusive), so [0,4).

Then there’s only one pair (q,r) that will satisfy the following equation $X = q\times m + r$

Example: What is 13 mod 5

13 = q * 5 + r → q = 2, r = 3 so 13 = 2 * 5 + 3 ☑️

13 mod 5 = 3

How about -2 mod 5?

-2 = q * 5 + r → q = -1, r = 3 so -2 = -5 + 3 ☑️

-2 mod 5 = 3

<aside> 💡 see these q and r pairs? they’re always unique, there is no more than one pair that can satisfy that equation for each integer.

</aside>

Notes: