How to efficiently compute $17^{23} (\mod 31)$ by hand? I could use that $17^{2} \equiv 10 (\mod 31)$ and express $17^{23}$ as $17^{16}.17^{4}.17^{3} = (((17^2)^2)^2)^2.(17^2)^2.17^2.17$ and take advantage of the fact that I can more easily work with powers of ten ($17^2 \equiv 10 (\mod 31), (17^2)^2 \equiv 100 (\mod 31) \equiv 7 (\mod 31)$, etc.). While this makes the computation easier, I'm thinking there might be a better way to do this.

We can do away with manipulating the powers of $17$ as follows
Observe that $17\equiv-14\pmod{31}$
$\displaystyle\implies 17^{23}\equiv(-14)^{23}\equiv-14^{23}\pmod{31}$
Now, $7^2=49\equiv18\pmod{31}, 7^3\equiv18\cdot7\equiv2\pmod{31}$
$\displaystyle\implies14^{23}=2^{23}\cdot7^{23}=2^{23}(7^3)^7\cdot7^2\equiv2^{23}\cdot2^7\cdot7^2\equiv2^{30}\cdot49\pmod{31}$
Using Fermat's Little Theorem, $2^{30}\equiv1\pmod{31}$
Alternatively, $2^5=32\equiv1\pmod{31}\implies 2^{30}=(2^5)^6\equiv1^6\pmod{31}\equiv1$
So, $\displaystyle-14^{23}\equiv-49\pmod{31}\equiv13$
