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}$.
| n | 5^n | 5^n mod 21 |
| 1 | 5 | 5 |
| 2 | 25 | 4 |
| 3 | 125 | 20 |
| 4 | 625 | 16 |
| 6 | 15625 | 1 |
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}$.