+0  
 
0
600
1
avatar

how to calculate the modulo of a negative number

 Feb 27, 2019
 #1
avatar+194 
0

It's calculated exactly like the mod of a positive number. In arithmetic modulo cc, we seek to express any xx as qc+rqc+r, where rr must be a non-negative integer.

 

Why don't we test it out with an example?

 

Take −100−100 mod 8=48=4. This is because of 8⋅−13=−1048⋅−13=−104. The remainder is 44.

So now let's take (37−54)(37−54) mod 55. It's equal to −17−17 mod 5=35=3. Substitute in and do the computation: Method 11 gives 33, which is what we want, and method 22 gives −2−2, so the correct approach is method 11  cool

 Feb 27, 2019

0 Online Users