# How to calculate (a−b)modn\,(a-b)\bmod n\, and −bmodn {-}b \bmod n [closed]

Consider the following expression:

(a - b) mod N


Which of the following is equivalent to the above expression?

1) ((a mod N) + (-b mod N)) mod N

2) ((a mod N) - (b mod N)) mod N


Also, how is (-b mod N) calculated, i.e., how is the mod of a negative number calculated?

Thanks.

I’m not trying to say that you are wrong for thinking of “mod” as an operation, because the operation of “taking a residue mod $m$” is a useful operation. However, I think it is also useful to keep the other meaning of “mod” in mind.