I don’t want to bother you with complex mathematical concepts, so I will try to make it simple. When we say that a = b (mod c), we simply say that ab is a multiple of c. This means that when we want to know what the value of mod c is, saying that it is a or ac or + c or + 1000 * c is true. So your 2 formulas are valid.
, , ?
, , .
Java, , mod b a , b. , a = 7, b = 3 N = 5, (a-b)% N = 4, -1.
, , , , . , 2 .
:
function mod (int a, int N)
return (a%N+N)%N