How to solve this congruence $17x \equiv 1 \pmod{23}$?

Algorithmically one can employ the Extended Euclidean Algorithm to invert $\,17\,$ modulo $\,23\,$ (possible since they are coprime). But for small numbers it is usually quicker to use other methods, e.g. rewriting $\,17^{-1} \equiv \frac{1}{17}$ as a fraction, then adding $\pm$modulus to the numerator and denominator until one obtains an exact quotient. Do this $\rm\color{#0a0}{first}$ to minimize the absolute value of the denominator (to increase the probability of an exact quotient), and $\rm\color{#c00}{then}$ do the same to the numerator, aiming to obtain a multiple of the denominator. For example

$${\rm mod}\ 23\!:\,\ 17x\equiv 1\,\Rightarrow\,x \,\equiv\, \dfrac{1}{\color{#0a0}{17}} \,\equiv\, \dfrac{\color{#c00}1}{\color{#0a0}{-6}}\,\color{#c00}\equiv\,\dfrac{\color{#c00}{24}}{-6} \,\equiv\, -4 \,\equiv\, 19\qquad\qquad$$

We subtracted $23$ from the denominator to get the minimal integer $\,\color{#0a0}{-6 \equiv 17}\pmod {23},\,$ then since $\,23\equiv -\color{#c00}{1}\pmod 6,\,$ we add it the numerator $(= \color{#c00}1)$ to make it be divisible by $6$.

Beware $\ $ For non-prime moduli one must be sure to restrict to denominators that are coprime to the modulus (so invertible), so to avoid the modular analog of dividing by zero.

In this example the described method ends up being essentially a special case of said algorithm, reinterpreted in fractional form. But that is not always so. The advantage of the fractional form is that it allows one to use well-known fractional arithmetic (subject to said restriction), e.g. cancelling common factors. One can find many worked examples is my prior posts.


By Fermat's little theorem, $a^{p-1} \equiv 1$ (mod p) for prime number p. So $x=17^{21}$ should work for sure. There can be smaller numbers satisfying this.


Hint: If you do not want to find result by trying numbers,

By Euclidean algorithm , you can find $m,n$ such that $$17m+23n=1$$ $$17m\equiv1 \ mod \ 23$$ so $m$ is the inverse of $17$ then result follows.