Is there an effective implementation of tetetation?

Recently, the answer to a question related to the Ackerman function, part of which included the function of calculating the number tetation. It made me wonder if there is a more efficient way to do this. I did some tests myself, but I limited myself mainly to the fact that even a number like 5 ^^ 3 = 5 ^ 3125 at 5 ^ 3 is about 10 ^ 2, which means 5 ^ 3125 ~ = 10 ^ (3125 * 2 / 3) about 2,000 digits.

The function makes it impossible to divide and capture methods due to the nature of how exponentiation is performed, i.e.

2 ^^ 5 = 2 ^ (2 ^ (2 ^ (2 ^ 2)))) = 2 ^ (2 ^ (2 ^ 4)) = 2 ^ (2 ^ 16) = 2 ^ 65536 ~ = 10 ^ ( 65536 * 3/10), so about 20 thousand digits ...

The nature of the problem, since it starts at the top of the tree of power and works in a way that strikes me as a factorial. You can use the fast power algorithm to perform the exponential operation, but I could not see a way to reduce the number of exponentiation operations.

In case someone is unclear what I'm saying here, the wiki article is essentially a tetition:

a ^^ b = a ^ a ^ a .... ^ a, b times, and then the erection to the top element of the power tree begins and runs down.

The algorithm I use will be (although I use the ruby ​​version if I really want the value):

long int Tetration(int number, int tetrate)
{
    long int product=1;
    if(tetrate==0)
        return product;
    product=number;
    while(tetrate>1)
    {
        product=FastPower(number,product);
        tetrate--;
    }
    return product;
}

Any thoughts would be appreciated.

+5
source share
3 answers

, d, - O (log d) , O (d) . , , . , , .

+4

, , :

a ↑↑ 2b = (a ^ a)

: a ↑ ⁿ 2b = (a ↑ ⁿ⁻¹ a) ↑ ⁿ b

:

for(long a = 2; a < 5; a++) {
        for(long b = 2; b < 5; b++) {
            if(b%2 == 0) {
                System.out.println(a+"↑↑"+b+"="+tetration(BigInteger.valueOf(a), BigInteger.valueOf(b)));
                long pow = (long) Math.pow(a, a); // pow = tetration(a,2)
                System.out.println(pow+"↑↑"+b/2+"="+tetration(BigInteger.valueOf(pow), BigInteger.valueOf(b/2)));
            }
        }
    }
0

, , :

<!DOCTYPE html>
    <html>
        <head>
            <script>
                var x = 1
                //That is β–½ The Number You Are Powering//
                var test = 3
                var test2 = test
                setInterval (function () {
                    // that is  β–½ How many times you power it so this would be 3 tetra 3      which is 7625597484987//
                    if (x < 3) {
                        document.getElementById('test').innerHTML = test=test2**test
                        x++
                    }
                }, 1);
            </script>
            <p id="test">0</p>
-1

All Articles