Saturday, March 16, 2019

modular arithmetic - How to find remainder of denominator is greater than numerator?



I am learning modular arithmetic and trying to figure out, how to find remainder where denominator is greater than numerator?



For example:



i) $2 \bmod 5 =$ ?




I tried to solve this but I got 0 as remainder whereas in calculators it is $2$ . I was solving it with regular math operators like adding 0 and value after points.



ii) $-2 \bmod 5$ = ?



Also I wanted to know, how to handle negative number in modular arithmetic?


Answer



Remember, by definition, the remainder when dividing $m/n$ is such a number $r$ such that





  1. $0\leq r
  2. There exists some $k$ such that $k\cdot n + r = m$



by that definition, the remainder when dividing $2$ by $5$ is $2$, because $$0\cdot 5 + 2 = 2$$






As far as modular arithmetic is concerned, remember that $$x\equiv y\mod n$$
if and only if $n|x-y$. As a consequence, it is always true that $$x+k\cdot n\equiv x\mod n$$ for any integer $k$. In your case, that means that $$-3\equiv -3+1\cdot 5\mod 5$$



No comments:

Post a Comment

analysis - Injection, making bijection

I have injection $f \colon A \rightarrow B$ and I want to get bijection. Can I just resting codomain to $f(A)$? I know that every function i...