Thursday 23 March 2017

modular arithmetic - Why is $-145 mod 63 = 44$?



When I enter $-145 \mod 63$ into google and some other calculators, I get $44$. But when I try to calculate it by hand I get that $-145/63$ is $-2$ with a remainder of $-19$. This makes sense to me, because $63\cdot (-2) = -126$, and $-126 - 19 = -145$.




So why do the calculators give that the answer is $44$?


Answer



I think you have to start with the more basic question, "What does $\text{mod}$ mean?"



When we say "$\pmod{63}$" what we really mean is: Pretend that the "number line" is bent around in a circle so that when counting up, after you hit $62$ you return to $0$. On such a "number circle", the numbers $5,68, 131, 194, \dots$ are all equal to each other. And you can count downwards, too: $68, 5, -58, -121, \dots$ are also all equal.



It's common to interpret $a \pmod{63}$ to mean "Find the number between $0$ and $62$ that is equal to $a$, mod $63$." You can always find such a number by repeatedly adding or subtracting 63 to your given number until you get it into the desired range.



In this case, $-145 = -82 = -19 = 44 = 107 = \dots$. The only result that lies between $0$ and $62$ is $44$.




Note, though, that you are not wrong in thinking that $-145 \pmod{63} = -19$. When working mod $63$, the numbers $-19$ and $44$ are identical.


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}...