0
$\begingroup$

I am trying to convince myself without using the calculator to compute the negative numbers that are moded by a positive number, i.e. ($-x \mod y$). I found out that if ($x<y$), then it is easy just by taking the difference between x and y: Example: $-10 \mod 17 = 17-10 = 7$.

However, I get stuck when $x>y$, For example, $-18 \mod 17 = 16$ so I really do not know how 16 comes up. Can someone explain how 16 is the answer? Or can you generalized the case ($x<y$)?

Thank you very much

$\endgroup$
2
  • 1
    $\begingroup$ In the particular case when $x < y$ you just add $y$ to $-x$. But the general idea does not require $x$ to be less than $y$. You can just add $2y,3y,4y...$ to $x$ (until it is not negative anymore) and they will all share the same equivalence class. In your example, if you add $34=2\cdot 17$ to $-18$ you get $16$ which is what you want. $\endgroup$
    – Levent
    Dec 10, 2016 at 18:33
  • 1
    $\begingroup$ Keep adding $17$ till you reach a nonegative integer (just like you keep subtracting $17$ when the initial value is $\ge 17)\ \ $ $\endgroup$ Dec 10, 2016 at 18:43

1 Answer 1

0
$\begingroup$

Take a closer look at the following property:

$c \equiv a \pmod b \equiv a\pm kb \pmod b$

When $a=-10 \Rightarrow 7 \equiv -10 \pmod{17} \equiv -27 \pmod{17} \equiv 24 \pmod{17}$

When $a=-18 \Rightarrow 16 \equiv -18 \pmod{17} \equiv -35 \pmod{17} \equiv -1 \pmod{17}$

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .