The other day I was playing around with some recursive functions, and I made a simple algorithm like this:
int f(int n) {
if (n == 0) return 1;
return f(f(n-1)-1) * n;
}
What is interesting is that it works for f(0), f(1), f(2), f(3) & f(4) but not matter what language or compiler I try it in, nothing seems to be able to complete f(5) without causing a stack overflow.
My question is how / where could I run this to find the solution to f(5) and also what might be the big-O complexity of a function like this?
The first couple results are 1,1,2,3,8...