<s>[INST] Find the least nonnegative residue Find the least nonnegative residue of $5^{18} \mod 11$. 
To do this I took $5^2 \equiv 3 \mod 11$. Then I did $(5^2)^5 \equiv 3^5 \mod 11$. And $3^5 \equiv 1 \mod 11$. 
So now I have $5^{10} \equiv 1 \mod 11$. Then I multiplied both sides by $5^8$ to get $5^{18} \equiv 5^8 \mod 11$.  So I believe $5^8$ is the least nonnegative residue but I am not entirely sure. Can someone please confirm that this is correct?
 [/INST] Best way to do this is to repeatedly divide the exponent by 2.
$$
18 = 2 \times 9, ~ 9 = 2 \times 4 + 1,~ 4=2 \times 2 
$$
So 
$$
5^2 = 25 \equiv 3 \mod 11
\\
5^4 \equiv 3^2 = 9 \mod 11
\\
5^8 \equiv 9^2 = 81 \equiv 4 \mod 11
\\
5^9 =5 \cdot 5^8 \equiv 20 \equiv 9 \mod 11
\\
5^{18} \equiv 9^2 = 81\equiv 4 \mod 11
$$
Hence the answer is $4$.
Note you can save a lot of work by noting that by Fermat's theorem $5^{10} \equiv 1\mod11$
Hence
$$5^{18} = 5^{10} 5^8 \equiv 5^8 \equiv 4 \mod 11$$
</s>