<s>[INST] Find the last digit of $77777^{77777}$ Find the last digit of $$77777^{77777}$$
I got a pattern going for $77777^n$ for $n=1, 2, ....$ to be:
$$7, 9, 3, 1$$ for $n = 1, 2, 3, 4$ respectively. 
The idea is:
$$77777^{77777} \pmod{10}$$
I see that:
$$77777^n  \equiv 77777^{n + 4} \pmod{10}$$
Using the spotted pattern, but letting $n = 77777$ doesnt help at all.
Please give hints only...!
 [/INST] $\varphi(10)
 = \varphi(2 \times 5) = \varphi(2) \times \varphi(5) = (2-1)(5-1) = 4
$
Since $\gcd(7,10) = 1,$ then $7^4 \equiv 1 \pmod{10}$
Note that $77777 \equiv 777 \times 100 + 76 + 1 \equiv 1 \pmod 4$
So
\begin{align}
   77777^{77777} \pmod{10}
      &\equiv 7^{77777} \pmod{10}\\
      &\equiv 7^{4(\text{something})+1} \pmod{10}\\
      &\equiv (7^4)^\text{something} \times 7^1 \pmod{10}\\
      &\equiv 1^\text{something} \times 7 \pmod{10}\\
      &\equiv 7 \pmod{10}
\end{align}
</s>