Trying to brush up on my modular arithmetic, and came across this problem.
Calculate $158^{158} \pmod {31}$.
Using the rule $a^b \pmod c = (a\pmod c)^b \pmod c$ I was able to reduce it to $3^{158} \pmod{31}$, which should be the same.
But from here, I'm stumped.
Which rule can I use to progress here? Or is there some immediately obvious solution already?
Thanks in advance for any help!