## Project Euler 188: Find the last digits of a tetration calculation.

#### Problem Description

The hyperexponentiation or tetration of a number a by a positive integer b, denoted by a↑↑b or ^{b}a, is recursively defined by:

a↑↑1 = a,

a↑↑(k+1) = a^{(a↑↑k)}.

Thus we have e.g. 3↑↑2 = 3^{3} = 27, hence 3↑↑3 = 3^{27} = 7625597484987 and 3↑↑4 is roughly 10^{3.6383346400240996*10^12}.

Find the last 8 digits of 1777↑↑1855.

#### Analysis

Using the optional third parameter of Python’s pow(x, y [,z]) function which calculates the modulo z of x to the power y (computed more efficiently than pow(x, y) % z) we loop through the pow function b times to calculate the tetration of a↑↑b. Modding the result by some power of 10, 10^{8} in this case, we can reduce this unwieldy number to its last 8 digits.

We can exit the loop early, reducing the number of iterations, when the modded result begins to repeat.

#### Project Euler 188 Solution

Runs < 0.001 seconds in Python 2.7.Use this link to get the Project Euler 188 Solution Python 2.7 source.

#### Answer

Slowly swipe from either end beginning with the white vertical bar to get an idea of the starting or ending digits. For less drama, just double click the answer area. The distance between the two bars will give you an idea of the magnitude. Touch devices can tap and hold the center of the box between the two bars and choose*define*to reveal the answer.

#### Afterthoughts

**Note:**The last eight digits remain constant by the eighth iteration regardless of the parameters of the tetration expression.- See also, Project Euler 48 Solution: Find the last ten digits of 1^1 + 2^2 + ... + 1000^1000.
- See also, Project Euler 97 Solution: Find the last ten digits of the non-Mersenne prime: 28433 × 2
^{7830457}+ 1.

*Project Euler 188 Solution last updated*

## Discussion

## No comments yet.