TITLE: computing ${{27^{27}}^{27}}^{27}\pmod {10}$
QUESTION [8 upvotes]: I'm trying to compute the most right digit of ${{27^{27}}^{27}}^{27}$.
I need to compute ${{27^{27}}^{27}}^{27}(\bmod 10)$.
I now that ${{(27)^{27}}^{27}}^{27}(\bmod 10) \equiv{{(7)^{27}}^{27}}^{27} (\bmod 10)$, so now I need to to compute ${({7^{27})}^{27}}^{27} (\bmod 10)$, since $\gcd(7,10)=1$ and $\phi(10)=4$, $7^{27}=7^{24}\cdot 7^3(\bmod 10)=1 \cdot 7^3 (\bmod 10)=3 (\bmod 10)$ - (Fermat theorem), so I am left with computing ${(3^{27}})^{27} (\bmod 10)$, again $\gcd(3,10)=1$, so $3^{27}= 3^{24}\cdot3^3 \equiv 7(\bmod 10)$, so as I see it the final cut should be again $7^{27}$ which I saw it is already $3 (\bmod 10)$.
Is it correct? what is the correct way to do that?
Thanks

REPLY [4 votes]: $\varphi(10)=4$  and $27$ is of the form $(4n+3)\; $.
Now $ {(4n+3)^{(4n+3)}} \equiv 3(\bmod 4)=4c+3\; $.
Clearly, ${(4n+3)}^{(4n+3)^{(4n+3)}}=(4n+3)^{(4c+3)}\equiv 3(\bmod 4)\; $.
This will be held true for any length of such powers of the form $4n+3$.
So ${27}^{27^{27^{27}}}\equiv 7^3(\bmod\ 10)\equiv 3(\bmod\ 10)\; \; $  as $7^4\equiv 1(\bmod\ 10)\; $ .