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