The fast growing hierarchy is a way of categorizing how fast functions are growing, defined the following way (for finite indices):
- \$ f_0(n)=n+1 \$
- \$ f_k(n)=f_{k-1}^n(n)\$ with \$f^n\$ meaning repeated application of the function f
Examples
f0(5) = 6
f1(3) = f0(f0(f0(3))) = 3+1+1+1= 6
f2(4) = f1(f1(f1(f1(4)))) = 2*(2*(2*(2*4))) = 2⁴*4 = 64
f2(5) = f1(f1(f1(f1(f1(5))))) = ... = 2⁵*5 = 160
f2(50) = f1⁵⁰(50) = ... = 2⁵⁰*50 = 56294995342131200
f3(2) = f2(f2(2)) = f2(f2(2^2*2))) = f2(8) = 2^8*8 = 2048
f3(3) = f2(f2(f2(3))) = f2(f2(2³*3)) = f2(2²⁴*24)=2⁴⁰²⁶⁵³¹⁸⁴*402653184 = ...
f4(1) = f3(1) = f2(1) = f1(1) = f0(1) = 2
f4(2) = f3(f3(2)) = f3(2048) = f2²⁰⁴⁸(2048) = ...
...
shortcuts:
f1(n) = f0(...f0(n))) = n+n*1 = 2*n
f2(n) = f1(... f1(n)...) = 2^n * n
Your goal is to write a program of function that given two positive integers \$k\$ and \$n\$ outputs \$f_k(n)\$
Rules
- Given unlimited time and using unbounded integer types the algorithm you program is using should compute the correct result of f_k(n) for arbitrarily large
n
andk
(even if the program will not finish in the lifetime of the universe) - Your program only has to work for values that fit in a signed 32-bit integer
- Supporting the case \$k=0\$ is optional
- This is code-golf, the shortest solution in bytes wins
Supporting the case 𝑘=0 is optional
correct? Shouldn't it readn=0
instead?k=0
is the recursion base, so you can't exclude it meaningfully. \$\endgroup\$f1(n)=2n
. Also, the domain is previously specified to be positive integers \$k,n\$. \$\endgroup\$n == 0
(with standard identity function \$ f^0(x) = x \$ forn == 0
), so I didn't expect to find such relaxation in this question. \$\endgroup\$