I'm trying to write a tail-recursive function of the Hofstadter sequence defined like this:
So far I've been able to write a recursive funcion which isn't tail-recursive:
int f_h(int n)
{
int h;
if(n==0){
return 0;
}
h = f_h(f_h(f_h(n-1)));
return(n-h);
}