What is the correct way of calculating $2^{3^{4^{5^{6^{7}}}}} \bmod 9$?
The first step is obviously to use Euler’s theorem since $\gcd(2,9) = 1$ and $\phi(9)=6$.
But then I have to calculate $3^{4^{5^{6^{7}}}} \bmod 6$, and since $\gcd(3,6) = 3 != 1$ then I cannot use Euler’s theorem.
I have looked on the internet and found incorrect ways like $3^{4^{5^{6^{7}}}} = 9^{2^{5^{6^{7}}}}$, but that’s wrong. What is the correct way to go about this? Thanks in advance.
If ${3^{4^{5^{6^{7}}}}} \equiv k \mod 6$ then
$2^{3^{4^{5^{6^{7}}}}}\equiv 2^k \mod 9$
${3^{4^{5^{6^{7}}}}} $ is a multiple of $3$. So ${3^{4^{5^{6^{7}}}}} \equiv 0,3 \mod 6$. ${3^{4^{5^{6^{7}}}}} \equiv 0 \mod 6$ if it is an even multiple of $3$ and ${3^{4^{5^{6^{7}}}}} $ if it is an odd multiple of three.
As the only prime factor of ${3^{4^{5^{6^{7}}}}} $ is $3$ it is an odd multiple of three.
So ${3^{4^{5^{6^{7}}}}} \equiv 3 \mod 6$
So $2^{3^{4^{5^{6^{7}}}}} \equiv 2^3 \equiv 8 \mod 9$.