Skip to main content

Posts

Showing posts from October, 2018

Basic Modular Arithmetic

In simple terms, Modular Arithmetic calculates the remainder of anything divided by anything. The later is called modulus. e.g. ( 15 / 7 ) Quotient: 2, Remainder 1.  In greater sense,  modular arithmetic  is a system of  arithmetic  for  integers , where numbers "wrap around" upon reaching a certain value—the  modulus ( src: Wikipedia ). Take a look at hour clock. After 12:59 pm, we say 1:00 pm, because we modulo the hours by 12. 13 pm % 12 is 1 pm. (%) represents modulus operator. Examples: 5 % 2 = 1, 14458948 % 25 = 23 a≡b (mod n) This says that a  A is  congruent  to b modulo n. It means both a and b has same remainder when divided by n. e.g. 38 ≡14 (mod 12) Commonly Used Properties: Reflexivity:  a  ≡  a  (mod  n ) Symmetry:   a  ≡  b  (mod  n )   if and only if   b  ≡  a  (mod  n ) Transitivity: If   a  ≡  b ...