Find remainder when $20^{13}$ is divided by $4940$
I have solved this, but am hoping for an elegant solution.
My solution:
$r(20^{13}||4940) = 20 \times r(20^{12}||247)$ where $r(a||b)$ is the remainder when $a$ is divided by $b$.
$20^3 \equiv 96 \mod 247 $
$20^6 \equiv 77 \mod 247 $
$20^{12} \equiv 1 \mod 247 $
So my answer is $20$.
But there must be a better way (This seems kind of brute force).
Any hints are welcome.
As $247=13\cdot19,$
Using Fermat's Little Theorem, $20^{13-1}\equiv1\pmod{13}$
and $20\equiv1\pmod{19}\implies20^{12}\equiv1^{12}\equiv1$
$\implies20^{12}\equiv1\pmod{\text{lcm}(13,19)}$