Modulus
m mod n
is the remainder of m ÷ n
3 mod 5 = 3
because 3 divided by 5 is 0 with remainder 3.m mod n = n
wherem < n
5 mod 3 = 2
because 5 divided by 3 is 1 with remainder 2.0 <= m mod n <= n
wherem > n
From 1.
0 mod 3 = 0
1 mod 3 = 1
2 mod 3 = 2
From 2.
3 mod 3 = 0
4 mod 3 = 1
5 mod 3 = 2
6 mod 3 = 0
-5 mod 3 = 1
because -5 divided by 3 is -2 with remainder 1. Remainders are never negative-5 = 3(-2) + 1