Learning Scientific Programming with Python (2nd edition)

P2.7.8: Tetration

Question P2.7.8

Tetration may be thought of as the next operator after exponentiation: where $x \times n$ can be written as the sum $x+x+x+\cdots + x$ with $n$ terms, and $x^n$ is the multiplication of $n$ factors: $x\cdot x \cdot x \cdots x$, the expression written $^nx$ is equal to the repeated exponentiation involving $n$ occurences of $x$: $$ ^nx = x^{x^{.^{.^x}}} $$ For example, $^42 = 2^{2^{2^{2}}} = 2^{2^{4}} = 2^{16} = 65536$. Note that the exponential "tower" is evaluated from top to bottom.

Write a recursive function to calculate $^nx$ and test it (for small, positive real values of $x$ and non-negative integers $n$: tetration generates very large numbers)!

How many digits are there in $^35$? In $^52$?