Wednesday, 8 March 2017

number theory - modular arithmetic question



know some rules for modular arithmetic expressions, for example,




  1. $A+B=C\implies ((A\bmod M) + (B\bmod M))\bmod M = C\bmod M$.



2.$A\times B=C\implies $((A\bmod M)\times (B\bmod M))\bmod M = C\bmod M$.




($A$, $B$, $C$, and $M$ are just constant arbitrary integers)



But I did not understand the following one
$$A - B = C \implies ( (A\bmod M)-(B\bmod M)+kM)\bmod M = C\bmod M$$
for some value $k$.



I am interested because, as I know, such methods are used in computing hash values of strings and generally related with string search methods. My question is, what does $k$ do in this case? Can we use arbitrary value of $k$? or how to calculate which value of $k$ is relevant for such calculation? Thanks a lot.


Answer



Do you know the meaning of modular arithmetic? If so then you will know that when you do any addition/subtraction/multiplication you might not get an answer that lies in the range 0,1,2,..., M-1 so you might have to manipulate your answer by a multiple of M


No comments:

Post a Comment

real analysis - How to find $lim_{hrightarrow 0}frac{sin(ha)}{h}$

How to find $\lim_{h\rightarrow 0}\frac{\sin(ha)}{h}$ without lhopital rule? I know when I use lhopital I easy get $$ \lim_{h\rightarrow 0}...