Hello to all, i try to implement modular arithmetic in C++ but finding it quite difficult to understand what is modular arithmetic.

I reading a book title: Algorithms by S. Dagupta, C H Papadimitriu, and U. V. Vaziran in chapter 1.


Substitution rule If x  x0 (mod N) and y  y0 (mod N), then:
x + y  x0 + y0 (mod N) and xy  x0y0 (mod N):

x + (y + z)  (x + y) + z (mod N) Associativity
xy  yx (mod N) Commutativity
x(y + z)  xy + yz (mod N) Distributivity
This content is taken from http://www.cs.berkeley.edu/~vazirani...thms/chap1.pdf


I hope someone can explain this to us.

Thanks for your help.