# Modular Exponentiation 8^5^4 [duplicate]

I am trying to find the last digit of $8^{5^4}$ (or $8^{(5^4)}$, if you will) using modular exponentiation. What I know is that the value I want is:

$8^{5^4} \mod 10$.

Normally I would find a pattern that $8^{n} \mod 10$ depends upon and use that information to know how to approach the $5^{4}$ term, but $8^{n} \mod 10$ doesn't seem to have a useful pattern.

I know that the answer is $8$ (via WolframAlpha) but I don't know how to connect the dots here. Any help would be appreciated.

Thanks!

## marked as duplicate by Jyrki LahtonenFeb 12 '15 at 6:58

• $8^n\mod 10$ goes in a cyclic pattern 8,4,2,6,8,4,2,6,... It repeats once every 4. So, the question is then what the exponent on 8 is mod 4, $5^4\mod 4 = 1^4 \mod 4 = 1$ – JMoravitz Feb 11 '15 at 3:17
• Ah, yes. You're right! I must've made an error somewhere. Thanks! – thisisourconcerndude Feb 11 '15 at 3:20

Examining powers of $8\pmod {10}$, we discover \begin{align} 8^2\equiv 4\pmod{10}\\ 8^3\equiv 2\pmod{10}\\ 8^4\equiv 6\pmod{10}\\ 8^5\equiv 8\pmod{10} \end{align}

So, $8^n\equiv 8\pmod{10}\iff n\equiv 1\pmod 4$. Of course $5\equiv 1\pmod 4$. Hence $5^4\equiv 1\pmod 4$. Therefore $8^{5^4}\equiv 8\pmod{10}$.

Hint $\,\ \color{#0a0}{8^{\large 5}\equiv 8}\ \Rightarrow\ 8^{\large 5^{\Large \color{#c00}{N+1}}}\! \equiv (\color{#0a0}{8^{\large 5}})^{\large 5^{\Large N}}\!\equiv\, \color{#0a0}8^{\large 5^{\Large \color{#c00}N}}\!\equiv\, 8^{\large 5^{\Large \color{#c00}{N-1}}}\equiv \cdots \equiv 8\$ by induction

i.e. fixed points stay fixed on iteration $\ f(a) = a\,\Rightarrow\, f^N(a) = a.\$ Above $\,f(a) = a^5.$

As $(8,10)=2$

let us find $8^{5^4-1}\pmod5$

As $\phi(5)=4,$ and $5\equiv1\pmod4\implies5^4\equiv1^4\equiv1\implies5^4-1\equiv0\pmod4$

$\implies8^{5^4-1}\equiv8^0\pmod5\equiv1$

Now using $a\equiv b\pmod m\implies a\cdot c\equiv b\cdot c\pmod{m\cdot c}$

Here $c=8\implies8^{5^4-1}\cdot8\equiv1\cdot8\pmod{5\cdot8}\equiv8\pmod{40}$

As $10|40,8^{5^4}\equiv8\pmod{10}$