Opposite of mod in a equation

$\begingroup$

I am trying to solve this module equation (due to a cryptography program that I am coding) but cannot figure it out how:

X + 7 % 10 = 6

How Do i solve this?

Thanks in advance.

$\endgroup$ 2

4 Answers

$\begingroup$

If $(x+7) \text{ mod } 10 = 6$, this means that $(x+7)$ has a remainder of $6$ when divided by $10$.

So $x \text{ mod } 10 = 9$, and therefore $x = 9, 19, 29, ...$

$\endgroup$ $\begingroup$

If $x+7\equiv 6\pmod{10}$, then you can proceed to solve it with exactly the same ideas as you would in non-modular arithmetic.

$x+7-7\equiv 6-7\equiv-1\pmod{10}$ and therefore

$x\equiv-1\equiv 9\pmod{10}$

So in general, if you want to solve $x+a\equiv b\pmod{10}$, you just compute $x\equiv b-a\pmod{10}$.

$\endgroup$ 2 $\begingroup$

What I would do is the following, even if it is not efficient:

Set $X=0$.

  • Check if $(X + 7) \% 10 == 6$

  • If yes, all the solutions are of the form $X + n\cdot 10$ for $n\in \mathbb{N}$

  • If not, $X=X+1$ and start again

  • If $X>10 - 1$, then there are no solutions. Break

$\endgroup$ 2 $\begingroup$

For completeness, I wanted to add that I think the opposite of mod is called div:

9 mod 2 = 1 (the remainder)
9 div 2 = 4 (the integer quotient)

I believe there are enough correct answers here for the rest of it.

$\endgroup$

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like