-1

I solve problems like this using trial and error especially when the given numbers are not that high. But I am trying to build a calculator to solve this modulus problem: 5x = 1 mod 7

What's the formula to solve it without trial and error? Thanks.

2 Answers2

0

Note that $5x\equiv 1\mod 7$ is the same as asking $5x+7k=1$ where $k\in\mathbb{Z}$.

The inverse of $5$ in modulus $7$ is $3$, because $5\cdot 3=15$ and $15\equiv 1 \mod 7$. Then calculate \begin{align*} 5x &\equiv 1 \mod 7\\ 5x\cdot 3 &\equiv 3 \mod 7\\ 15x&\equiv 3\mod 7\\ x&\equiv 3 \mod 7 \end{align*} It follows that $x=7k+3$, so for example $x=3$ and in more general notation $5_{[7]}^{-1}=3$.

To find inverses for any $a \mod m$ you need to consider the equation $k\cdot x+m\cdot y=1$ and solve it with the extended euclidean algorithm. $x$ will be the inverse of $a$, i.e. $ax\equiv 1\mod m$.

You can always find a multiplicative inverse if $m$ is prime (like in your case, $7$ is prime so $1,\dots,6$ all have inverses), otherwise only some integers in $\mathbb{Z}_m$ will have inverses.

-1

We note that, for any integer $x$, we have $$ 5x \equiv 1 \mod 7 \tag{1} $$ if and only if $$ 7 | (5x - 1), $$ that is, there exists some integer $q$ for which $$ 5x - 1 = 7q, $$ and thus $$ 5x - 7q = 1. \tag{2} $$

As $\gcd (5, -7) = 1$, so we can express this $\gcd$ as a linear combination of $5$ and $-7$ as $$ 1 = 5(3) - 7(2). $$ Thus one solution of (1) is $x \equiv 3 \mod 7$.