There are many examples on math SE on how to use Euler's theorem to compute modulos of large powers. Yet, I can't seem to find a solution to the following problem:
Compute $1808^{80085^{2014}} \mod 17$
Euler's theorem is $a^{\phi(n)} \equiv 1 \mod n \iff gcd(a,n) = 1$
The solution is as follows:
$ \begin{align} &1808^{80085^{2014}} & \mod 17 \\ =& 6^{80085^{2014} mod \phi(17)} & \mod 17 \\ =&6^{5^{2014 \mod \phi(16)} \mod 16} & \mod 17 \\ =&6^{5^{2014 \mod 8} \mod 16} & \mod 17 \\ =&6^{5^{6} \mod 16} & \mod 17 \\ =&6^{9} & \mod 17 \\ =&11 \end{align} $
I know how to compute $\phi(n)$, I know that $1808 \mod 17 = 6$, but how does $6^{80085^{2014} mod \phi(17)} \mod 17$ follow from $1808^{80085^{2014}} \mod 17$?
That is because $n^m \equiv (n-17)^m \mod 17$ thus
$$n^m \equiv (n \mod 17)^m \mod 17$$
$$1808^m \equiv(1808 \mod 17)^m \equiv 6^m \mod 17$$
then you have
$$6^m \equiv 6^{m \mod \phi(17)} \mod 17$$ due to Euler's theorem.
Detail:
$$ 6^{\phi(17)} \equiv 1\mod 17$$ thus $$ 6^m = 6^{m-\phi(17)}\cdot 6^{\phi(17)} \equiv 6^{m-\phi(17)}\cdot1 \equiv 6^{m-\phi(17)}\mod 17$$ so $$6^m \equiv 6^{m \mod \phi(17)} \mod 17$$