a % N = x means that for some integers 0 <= x < N and m : m * N + x = a .
You can simply deduce that if a % N = x and b % N = y , then
(a + b) % N = = (m * N + x + l * N + y) % N = = ((m + l) * N + x + y) % N = = (x + y) % N = = (a % N + b % N) % N.
We know that 0 < x + y < 2N , so you need to save the remainder calculation. This shows that you can separate the summation and calculate the balances separately, and then add them, but do not forget to get the balance for the sum.
For multiplication:
(a * b) % N = = ((m * N + x) * (l * N + y)) % N = = ((m * l + x * l + m * y) * N + x * y) % N = = (x * y) % N = = ((a % N) * (b % N)) % N.
That way you can also do the same with the products.
These properties can simply be deduced in a more general form using some abstract algebra (the remainders form the factor ring Z/nZ ).
bandi
source share