Open Question: how to find modulus of negative numbers?


x mod n where x<0

x mod n = (x + kn) mod n .. [Choosing k so kn > |x|]

so -17 mod 5 … [ Choose k=4 as 4*5 > |-17| ]
= (-17 + 4*5) mod 5
= 3 mod 5
= 3

View the original article here