# Find the least positive residue of $5^{16} \bmod 17$

I need some help on finding the least positive residues. Not sure what the correct approach is to take on these types of problems and the book I'm reading isn't helping me.

** UPDATE **

If 17 was not prime how would I solve this problem? For example, find the least positive residue of $5^{16} \bmod 18$.

• Hint: Use Fermat's little theorem. – Enigma Oct 11 '14 at 21:41
• For more general cases look into Euler's theorem, which basically generalizes Fermat's little theorem. Link:en.wikipedia.org/wiki/Euler%27s_theorem – Enigma Oct 11 '14 at 21:42
• @user176252 Notice that $18$ is relatively prime with $6$ positive numbers smaller than itself (namely $1, 5, 7, 11, 13, 17$). According to Euler's theorem and since $16 \equiv 4 \pmod{6}$, it follows that $5^{16} \equiv 5^4 \pmod{18}$. Furthermore, $5^4 \equiv 25^2 \equiv 7^2 \equiv 49 \equiv 13 \pmod{18}$. – Mohith Oct 11 '14 at 22:00

Since $17$ is a prime, by the Fermat's little theorem we have: $$5^{16}\equiv 1\pmod{17}.$$
In this case here you can use that the exponent $16$ is a power of $2$: $2^4 = 16$:
$$5^{16} \equiv (5^8)^2 \equiv \ldots \equiv (((5^2)^2)^2)^2 \equiv ((25^2)^2)^2 \equiv ((8^2)^2)^2 \equiv (64^2)^2 \equiv (13^2)^2 \equiv 169^2 \equiv 16^2 \equiv (-1)^2 \equiv 1 \mod 17$$