How do I solve $18^{{20}^{19}}$ divided by 7?

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$.


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} $