I came across this challenge.
Find the last ten (least significant) decimal digits of $x$ = 2^(3^(4^(5^(6^(7^(8^9)))))).
First some notation. Let
$x_n = n^{(n+1)^{(n+2)^{.^{.^{.^9}}}}}$
denote the tower beginning at the integer base $n$ and ending at 9. So,
$x_2 = 2^{3^{4^{.^{.^{.^9}}}}}$,
$x_3 = 3^{4^{5^{.^{.^{.^9}}}}}$,
$x_4 = 4^{5^{6^{.^{.^{.^9}}}}}$ and so on.
The obvious way to find the digits is to reduce $x_2$ modulo $10^{10}$. The first thing I thought of is Euler's theorem. But the base (2) and the modulus ($10^{10}$) are not coprime. So the next tool to use is the Chinese remainder theorem.
- $10^{10}=2^{10}5^{10}$
- $x_2$ mod $2^{10}$ is zero because the exponent of 2 is larger than 10.
- $x_2$ mod $5^{10}$ can be found using Euler's theorem.
- Now reduce $x_3$ modulo $\phi(5^{10})=5^{10}-5^9=2^25^9.$
- 3 is coprime to both 2 and 5 so we can apply Euler's theorem again.
- Now reduce $x_4$ modulo $\phi(\phi(5^{10}))=\phi(5^{10}-5^9)=\phi(2^25^9)=(2^2-2)(5^9-5^8)....$
This becomes repetitive, confusing, and messy real fast because you have to keep track of everything as you climb up the tower and then put everything together as you come back down. I see that you only have to climb up to where the base is 5 but I am convinced that there must be a faster and a more elegant solution.
My question is, what is the fastest/most-elegant way to solve this problem? I have been wrestling with this for weeks and I do have the digits. But is there a particular trick or insight that I am missing here? If yes, then what is it?
I would prefer that the solution doesn't require anything beyond a standard-undergrad-intro-to-number-theory course, paper, pencil, and a basic calculator (to calculate powers quickly, etc.) but any tricks/shortcuts are welcome.