# How to calculate $p={{{{{{6^6}^6}^6}^6}^6}^6}$ $\mod7$?

I've tried two approaches:

Approach 1

Since $6 \equiv -1 \pmod7$

So, $p=(-1)^t$ and $t$ is even

Therefore, $p=1$.

Approach 2

Since $6 \equiv -1 \pmod7$

So, $6^6 \equiv 1 \pmod7$.

Hence, solving towers from top to bottom:

$p \equiv {{{{{6^6}^6}^6}^6}^1} \pmod7$

$p \equiv {{{6^6}^6}^1} \pmod7$

$p \equiv {6^1} \pmod7$

Therefore, $p=6$.

Now, I don't know why both the approaches are giving different answers and which one is right.

• By your second method $2^6 \equiv 2$ (mod 5) – N.S.JOHN Oct 12 '16 at 7:04

You can't replace exponents like that. That is, $6^8\not\equiv 6^1$ mod $7$. You can pretty easily check that $6^8\equiv 1$.

As you say, $6\equiv -1$, so $-1$ to an even power will give you $1$ mod $7$.

• Shouldn't that be $6^8 \equiv 1 ~\mod 7$? – erfink Oct 12 '16 at 7:05
• Right, thanks.  – Elliot G Oct 12 '16 at 7:06
• I've not replaced $6^8$ by $6$ anywhere but instead replaced $6^6$ by 1 – ankit Oct 12 '16 at 7:07
• That was an example – Elliot G Oct 12 '16 at 7:08
• I've not considered equality anywhere. only congruence – ankit Oct 12 '16 at 7:09

Approach $1$ is correct.

We do not have $$a^b \equiv a^{(b \mod p)} \mod p$$ in general

Third approach. $7$ is prime. $gcd (6,7)=1$ so by Fermats Little theorem $6^6\equiv 1 \mod 7$.

So $6^{6*k}\equiv 1 \mod 7$ (notice congruence of exponents are NOT preserved modulo 7-- but they are preserved modulo 6.)

So as ${{{6^6}^6}^6}$ is a multiple of $6$ we have ${{{{6^6}^6}^6} ^6}\equiv 1 \mod 7$

Question: $p={{{{{{6^6}^6}^6}^6}^6}^6}$ $\mod7$?

• a) Let $Q = {{{{6^6}^6}^6}^6}$ so that $p = 6^{6^Q}$

• b) Note that $6\equiv -1 \pmod 7$

Thus

• $\qquad \displaystyle p=6^{6^Q} = 6^{2^Q \cdot 3^Q} \equiv \left((-1)^{2^Q}\right)^{3^Q} \equiv 1^{3^Q} \equiv 1 \pmod 7$