I am learning modular arithmetic and trying to figure out, how to find remainder where denominator is greater than numerator?
For example:
i) 2mod5= ?
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) −2mod5 = ?
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⋅n+r=m
by that definition, the remainder when dividing 2 by 5 is 2, because 0⋅5+2=2
As far as modular arithmetic is concerned, remember that x≡ymodn
if and only if n|x−y. As a consequence, it is always true that x+k⋅n≡xmodn
No comments:
Post a Comment