How do I solve $18^{{20}^{19}}$ divided by 7? I was re-practicing some number theory and I came across this question that I had previously solved and it seems like... I can't solve it anymore. My thoughts are that $18^6 \equiv 1 \text{ mod } 7$ by Euler's formula so I am looking to express the power $20^{19}$ as some $6k + r$ to simplify the system. Doing this I get:
$$20 \equiv 2  \text{ mod } 6\\ 20^2 \equiv 4\text{ mod } 6\\ 20^3 \equiv 2 \text{ mod } 6$$
...and there seems to be no end as they repeat in 2, 4, 2 cycles. I can't seem to simplify this equation any other way though.. Could someone please enlighten me and suggest ways of viewing (or improving) on my problem solving skills when attacking problems like these?
 A: It seems like you have done enough to answer the question without very much more work. 
You have effectively determined that $20^{19} \equiv 2 \bmod 6$, so $18^{\large{20^{19}}} \equiv 18^{2} \bmod 7$ and the rest is simple.

Added a note on the cycles:
If you have $n>m$ and $a^n \equiv a^m \bmod b$, then clearly $a^{n+1} \equiv a^{m+1} \bmod b$ etc. and the sequence of equivalent values for $a^k \bmod b$ seen between $n$ and $m$ will repeat again (and again) above $n$.
A: Since $\gcd(18,7)=1$, by Euler's theorem, $18^{\phi(7)}\bmod{7}=1$.
Since $7$ is prime, $\phi(7)=7-1=6$.
Therefore $18^{6}\bmod{7}=1$.

There exists a positive integer $n$ such that:
$20^{19}=$
$6n+(20^{19}\bmod{6})=$
$6n+((20\bmod{6})^{19}\bmod{6})=$
$6n+(2^{19}\bmod{6})$

Therefore:
$18^{20^{19}}\bmod{7}=$
$18^{6n+(2^{19}\bmod{6})}\bmod{7}=$
$18^{6n}\cdot18^{(2^{19}\bmod{6})}\bmod{7}=$
$(18^{6})^{n}\cdot18^{(2^{19}\bmod{6})}\bmod{7}=$
$(\color\red{18^{6}\bmod{7}})^{n}\cdot18^{(2^{19}\bmod{6})}\bmod{7}=$
$\color\red{1}^{n}\cdot18^{(2^{19}\bmod{6})}\bmod{7}=$
$18^{(2^{19}\bmod{6})}\bmod{7}$

Let's prove by induction that if $n$ is odd then $2^{n}\bmod{6}=2$:
First, show that this is true for $n=1$:
$2^{1}\bmod{6}=2$
Second, assume that this is true for $n=2k+1$:
$2^{2k+1}\bmod{6}=2$
Third, prove that this is true for $n=2k+3$:
$2^{2k+3}\bmod{6}=$
$2^{2k+2+1}\bmod{6}=$
$2^{2+2k+1}\bmod{6}=$
$2^2(2^{2k+1})\bmod{22}=$
$2^2(\color\red{2^{2k+1}\bmod{6}})\bmod{6}=$
$2^2(\color\red{2})\bmod{6}=$
$8\bmod{6}=$
$2$
Therefore, since $19$ is odd, $2^{19}\bmod{6}=2$.

From all of the above, we can conclude:
$\begin{align}
18^{20^{19}}\bmod{7}
 &= 18^{(20^{19}\bmod{6})}\bmod{7} \\
 &= 18^{(2^{19}\bmod{6})}\bmod{7} \\
 &= 18^{2}\bmod{7} \\
 &= 324\bmod{7} \\
 &= 2 
\end{align}
$
A: ${\rm Recall\ that\ \ } ca\bmod cn\,=\, c\,(a\bmod n)\, =\, $ mod Distributive Law  
$\!{\begin{align}{\rm Therefore}\ \ \color{#c00}{20^{\large 19}}\!\bmod\color{#0a0}{\bf 6}&=\, 2\,(10\,\cdot\,  20^{\large 18}\bmod 3)\\ &=\, 2\,(1\cdot (-1)^{\large 18}\!\bmod 3)\\  &=\, \color{#c00}2\end{align}} $ 
So $\smash[t]{\, {\rm mod}\ 7\!:\ 18^{\Large\color{#c00}{20^{\LARGE 19}}}\! \equiv\, 18^{\Large\color{#c00}{\Large 2}}\equiv 4^{\large 2}\equiv 2},\ $ by $\,18^{\Large\color{#0a0}{\bf 6}}\!\equiv 1\,$  by Fermat.
