Solving the congruence $7x \equiv 41 \mod{13}$

I have to solve the following linear congruence:

$$7x \equiv 41 \mod{13}$$

The question where I got this from comes in two parts. The first is that it asks to find the set of the inverses of $$7 \mod 13$$, which turns out to be $$_{13}$$ but, I found that solution by solving the linear diophantine equation $$7x - 13k - 41$$ which is just the original equation in disguise i.e. $$7x \equiv 41 \mod{13}$$.

Now, I'm terribly confused as to the solution of the congruence equation. Where am I going wrong and how should I proceed?

Thanks!

EDIT: From @Bill's hint

\begin{align} 7x &\equiv 41 \mod{13} \\ x &\equiv \frac{41}{7} \mod{13} \\ x &\equiv \frac{28}{7} \mod{13} \quad (?) \\ x &\equiv 4 \mod{13} \\ \end{align}

Then, this gives me the solution $$_{13}$$.

• That $2$ is the inverse of $7$ is clear, now multiply through by $2$. – André Nicolas Apr 8 '14 at 0:31

Reduce the congruence to $7x \equiv 2$. Since $\gcd(7,13) = 1$, there exists a unique inverse of $7$ modulo $13$. Note that the inverse is just $2$ since $7 \cdot 2 \equiv 1 \pmod {13}$. Then it follows that $(7)(7^{-1})x \equiv x \equiv 2(7^{-1}) \equiv 4 \pmod {13}$ and that is the solution set.

• How did you arrive at $7x \equiv 2$? Is that because of $_{13}$? Also, I'm confused with your last two sentences, can you please clarify more? – Jeel Shah Apr 8 '14 at 0:36
• From $41 \equiv 2$. A general tip is to always reduce the residue $r$ to $0 \le r \le p-1$ when taking modulo $p$. Then another property of modular arithmetic is that we define the inverse of $r$ mod $p$ as $r^{-1}$ such that $r \cdot r^{-1} \equiv 1$. Then, we must multiply by the inverse for both sides. – Sandeep Silwal Apr 8 '14 at 0:39
• ahhh! I think I'm getting it now. Thanks! – Jeel Shah Apr 8 '14 at 0:54
• @gek This can be considered a special case of Gauss's algorithm - see my answer for a link to that. – Bill Dubuque Apr 8 '14 at 0:58

Hint $$\ {\rm mod}\ 13\!:\ \dfrac{41}7 \equiv \dfrac{28}7 = 4\ \$$ by $$\ \ 41\equiv 41\!-\!13 = 28$$

Alternatively $$\ \dfrac{41}{7}\equiv\dfrac{(-2)(-1)}{-6}\equiv \dfrac{-2}{-2}\dfrac{12}3\equiv 4\ \$$ by $$\ \ \begin{eqnarray}41&&\equiv\ \ 2\\ 7 &&\equiv -6\end{eqnarray}$$

Alternatively $$\ \dfrac{41}{7}\equiv \dfrac{2}7\equiv \dfrac{4}{14}\equiv \dfrac{4}1\$$ by Gauss's Algorithm.

Such twiddling (adding/subtracting the modulus from numerator or denominator till things divide or factor nicely) works quite well for small numbers (more generally we can use Inverse Reciprocity to make the quotient exact. For larger numbers one can invert the denominator by the Extended Euclidean Algorithm, or Gauss's algorithm if the modulus is prime.

Beware $$\$$ The use of fractions in modular arithmetic is valid only when the denominator is invertible, i.e. coprime to the modulus. Otherwise the quotient need not be unique, for example mod $$\rm\:10,\:$$ $$\rm\:4\,x\equiv 2\:$$ has solutions $$\rm\:x\equiv 3,8,\:$$ so the "fraction" $$\rm\:x \equiv 2/4\pmod{10}\,$$ cannot designate a unique solution of $$\,4x\equiv 2.\,$$ Indeed, the solution is $$\rm\:x\equiv 1/2\equiv 3\pmod 5,\,$$ which requires canceling $$\,2\,$$ from the modulus too, since $$\rm\:10\:|\:4x-2\iff5\:|\:2x-1.\:$$

Generally the grade-school rules of fraction arithmetic apply universally (i.e. in all rings) where the denominators are invertible. This fundamental property will be clarified conceptually when one learns in university algebra about the universal properties of fractions rings and localizations.

• This may be a stupid question but how do you arrive at this hint? Please, see my edit. – Jeel Shah Apr 8 '14 at 0:41
• Add or subtract the modulus from the numerator or denominator till you get numbers that divide or factor nicely. Such twiddling works well for small numbers. For bigger ones use brute-force inversion algorithms such as the extended Euclidean algorithm. – Bill Dubuque Apr 8 '14 at 0:45
• That last edit was very helpful. Thanks! – Jeel Shah Apr 8 '14 at 0:55

$$\tag{1} 7 x - 13k = 41$$

Let $a = x - 2k$, so $$\tag{2}x = a + 2k$$.

Substituting $(2)$ into $(1)$: $$7(a + 2k) - 13k = 41$$ $$7a + k = 41$$ $$k = 41 - 7a \tag{3}$$

Substituting $(3)$ into $(2)$: $$x = a + 2(41 - 7a)$$ $$x = 82 - 13a$$ Plug any integer you like into $a$, and out pops a valid $x$.

The OP states

... but, I found that solution by solving the linear diophantine equation

From this site I found Here the equation is $$7x\equiv 41 \pmod {13}$$ or

$$\tag 1 7x\equiv 2 \pmod {13}$$

Here also, multiplication $$7 \times x$$ is repeated addition. So you can also get the inverse of $${_{13}}^{-1}$$ and/or the solution of $$\text{(1)}$$ using the same technique (might as well cycle through it all):

$$\quad 7 \times 1 \equiv 0 + 7 \equiv 7$$
$$\quad 7 \times 2 \equiv 7 + 7 \equiv 1$$
$$\quad 7 \times 3 \equiv 1 + 7 \equiv 8$$
$$\quad 7 \times 4 \equiv 8 + 7 \equiv 2$$
$$\quad 7 \times 5 \equiv 2 + 7 \equiv 9$$
$$\quad 7 \times 6 \equiv 9 + 7 \equiv 3$$
$$\quad 7 \times 7 \equiv 3 + 7 \equiv 10$$
$$\quad 7 \times 8 \equiv 10 + 7 \equiv 4$$
$$\quad 7 \times 9 \equiv 4 + 7 \equiv 11$$
$$\quad 7 \times 10 \equiv 11 + 7 \equiv 5$$
$$\quad 7 \times 11 \equiv 5 + 7 \equiv 12$$
$$\quad 7 \times 12 \equiv 12 + 7 \equiv 6$$
$$\quad 7 \times 13 \equiv 6 + 7 \equiv 0$$

Looking over your work you can pick out both the inverse and the solution.

You can set up a spreadsheet to handle these problems and/or check your work.