Create the slowest growing function you can in under 100 bytes
Brachylog, 100 bytes
llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
Try it online!
This is probably nowhere near the slowness of some other fancy answers, but I couldn't believe noone had tried this simple and beautiful approach.
Simply, we compute the length of the input number, then the length of this result, then the length of this other result... 100 times in total.
This grows as fast as log(log(log...log(x), with 100 base-10 logs.
If you input your number as a string, this will run extremely fast on any input you could try, but don't expect to ever see a result higher than 1 :D
Haskell, 98 bytes, score=fε0−1(n)
_#[]=0
k#(0:a)=k#a
k#(a:b)=1+(k#(([1..k]>>fst(span(>=a)b)++[a-1])++b))
f n=[k|k<-[0..],k#[k]>n]!!0
How it works
This computes the inverse of a very fast growing function related to Beklemishev’s worm game. Its growth rate is comparable to fε0, where fα is the fast-growing hierarchy and ε0 is the first epsilon number.
For comparison with other answers, note that
- exponentiation is comparable to f2;
- iterated exponentiation (tetration or ↑↑) is comparable to f3;
- ↑↑⋯↑↑ with m arrows is comparable to fm + 1;
- The Ackermann function is comparable to fω;
- repeated iterations of the Ackermann function (constructions like Graham’s number) are still dominated by fω + 1;
- and ε0 is the limit of all towers ωωω⋰ω.
JavaScript (ES6), Inverse Ackermann Function*, 97 bytes
*if I did it right
A=(m,n)=>m?A(m-1,n?A(m,n-1):1):n+1
a=(m,n=m,i=1)=>{while(A(i,m/n|0)<=Math.log2(n))i++;return i-1}
Function A
is the Ackermann function. Function a
is supposed to be the Inverse Ackermann function. If I implemented it correctly, Wikipedia says that it will not hit 5
until m
equals 2^2^2^2^16
. I get a StackOverflow
around 1000
.
Usage:
console.log(a(1000))
Explanations:
Ackermann Function
A=(m,n)=> Function A with parameters m and n
m? :n+1 If m == 0, return n + 1; else,
A(m-1,n? :1) If n == 0, return A(m-1,1); else,
A(m,n-1) return A(m-1,A(m,n-1))
Inverse Ackermann Function
a=(m,n=m,i=1)=>{ Function a with parameter m, with n preinitialized to m and i preinitialized to 1
while(A(i,m/n|0)<=Math.log2(n)) While the result of A(i, floor(m/n)) is less than log₂ n,
i++; Increment i
return i-1} Return i-1