Calculate $a^b \mod c$

166 Views Asked by At

Let's say we have the expression $a^b \mkern-10mu\mod\! c$ and $b$ is really large, e.g. $37^{165}\mkern-10mu\mod 65$.

How to work this out by hand?

There's a way to avoid the large exponent.