Monday, 6 April 2026

Exercise (6.1).6

Find the order of 5 modulo 21. Hence, or otherwise, solve

$$ 5x \equiv 16 \pmod {21} $$


Since $\gcd(21,5)=1$ Euler's Theorem tells us $5^{\phi(21)} \equiv 1 \pmod {21}$. This means the order if a factor of $\phi(21)=12$. These factors are 1, 2, 3, 4, 6, 12, and are the only ones we need to test.

The following calculations show $5^6 \equiv 15625 \equiv 1 \pmod {21}$.

n5^n5^n mod 21
155
2254
312520
462516
6156251

The order of 5 modulo 21 is 6.


This means

$$ 5^6 \equiv 1 \pmod {21} $$

Factorising

$$ 5 \times (5^5) \equiv 1 \pmod {21} $$

So the inverse of 5 modulo 21 is $5^5 \equiv 3125 \equiv to 17 \pmod {21}$.


We can use the inverse to solve the linear congruence.

$$ \begin{align} 5x & \equiv 16 \pmod {21} \\ \\  17 \times 5 \times x \equiv 17 \times 16 \pmod {21} \\ \\ x & \equiv 272 \pmod {21} \\ \\  & \equiv 20 \pmod {21}  \end{align} $$

So the solution is $x \equiv 20 \pmod {21}$.