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
- $0\leq r
- 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