1

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.

  • 5
    Do you mean $(x+7) % 10 = 6$? – LeeNeverGup Jan 15 '14 at 18:25
  • Also be mindful of the difference between remainder and modulus when implementing your code. http://blogs.msdn.com/b/ericlippert/archive/2011/12/05/what-s-the-difference-remainder-vs-modulus.aspx – John Jan 15 '14 at 18:35

4 Answers4

1

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}$.

rschwieb
  • 153,510
1

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, ...$

John
  • 26,319
0

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.

Jeff
  • 325
  • 3
  • 8
0

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

Abramo
  • 6,917