I want to compute last few digts (as much as possible ) of the following number $$ N:=n^{n^{n^{\cdot^{\cdot^{\cdot^n}}}}}\!\!\!\hspace{5 mm}\mbox{ if there are $k$ many $n$'s in the expression and $n\in\mathbb{N}$ }$$ I have seen many particular cases of this problem. I think for odd $n$ the units digit is $n^3\mbox{ mod } 10 $ and for even $n$ the units digit is 6, for all $k\geq 3$ . How much can we say about the other digits ?
Last few digits of $n^{n^{n^{\cdot^{\cdot^{\cdot^n}}}}}$
-
0Unless you'll write out the brackets, $N$ is not clearly defined. – 2012-07-03
-
0@penartur I dont see any problem with the definition of $N$ – 2012-07-03
-
3$3^{(3^3)} = 3^{27} \ne 3^9 = 3^{3 \times 3} = (3^3)^3$. The operation of raising to the power is not associative. – 2012-07-03
-
3Whilst this is true, I think the usual convention is that the brackets start from the top. So $x^{y^z}$ becomes $x^{(y^z)}$ – 2012-07-03
-
9By $n^{n^{n^n}}$ I mean $n^{(n^{(n^n)})}$ and I think this is usually meant by what I wrote – 2012-07-03
-
2You can write it using Knuth's up-arrow notation as $n\uparrow\uparrow k$, that way there's no ambiguity. ;) – 2012-07-03
-
0Also, you say it's $n^3$ -- where is $k$? it is easily not true for e.g. $k=0$, or if you want $k\neq 0$, then $n=k=2$. You also need to specify what kind of answer you're expecting. There is a way to calculate all the digits: just calculate the entire expression! But that's not what you want, is it? – 2012-07-03
-
0@tomasz that is true for all $k\geq 4$ I have edited it. Thanks – 2012-07-03
-
1http://math.stackexchange.com/a/162608/26068 This may be helpful – 2012-07-03
-
0Basically i want know whether there are some good techniques to predict the digits without calculating the whole expression ( and i think this is not possible even for n=2 and k=10 within the lifetime of universe). – 2012-07-03
-
0This is known as tetration and there's a forum devoted to it at http://math.eretrandre.org/tetrationforum/index.php. – 2012-07-03
-
0I realized that for even $n$ and $k\geq 3$ the units digit is different, it is 6. I edited this. – 2012-07-03
-
0See http://oeis.org/A183613 and references there. – 2012-07-03
2 Answers
Taking $n=7$ and looking for the last three digits for an example, note that $7^m \pmod {1000}$ is periodic with period $20$. You can check this easily with a spreadsheet. So now, we only need the tower above the first $7$ to $\pmod {20}$. That has period $4$, so we only need the tower above the first two $7$'s $\pmod 4$. That has period $2$, and the stack above the bottom three $7$'s is always odd. So a tower of $k\ 7$'s has last three digits the same as $7^{7^7}$ for $ k \ge 4$. The upper $7$ is $3 \pmod 4$, so $7^7 \equiv 3 \pmod {20}$, so $7^{7^7} \equiv 343 \pmod {1000}$, so any taller tower ends in $343$
-
0I think if this is true for $n=7$ then it is also true for any $n$ with last three digits $007$ – 2012-07-03
-
0@pritam: you are correct – 2012-07-03
-
0Except that $7^7 \equiv 3 \mod 20$ and $7^{7^7} \equiv 343 \mod 1000$. – 2012-07-03
-
2@RobertIsrael: Thanks. Off-by-one error in my calcs. Fixed now. – 2012-07-03
-
0... and similarly $7 \uparrow \uparrow j \equiv 2343 \mod 10^4$ for $j \ge 3$, $172343 \mod 10^6$ for $j \ge 4$, $65172343 \mod 10^8$ for $j \ge 6$, ... – 2012-07-03
Here's a little bit of computational knowledge...
If we want the first $d$ digits, we can calculate the result by modular arithmetic. In other words, modulo $10^d=2^d5^d$.
The more time-consuming portion is calculating the result modulo $5^m$. We can note that $$k^m \mod n \equiv k^{m \mod \phi(n)} \mod n$$ where $\phi(n)$ is Euler's Totient function.
We can apply this function recursively, i.e. $$m^m \mod n \equiv m^{m \mod \phi(n)} \mod n$$ $$m^{m^m} \mod n \equiv m^{\left(m^m \mod \phi(\phi(n))\right) \mod \phi(n)} \mod n$$ $$\dots$$ where $n=5^d$. Therefore, the most extensive operation is exponentiation modulo $n$. This can be done in $O(\log(n))$ operations via exponentiation by squaring or binary exponentiation. This operation is done at most $n$ times, so we get a conservative bound of $O(n \log(n))$ or, really, $O(5^d \log(5^d))$ operations.