Hofstadter序列在c中使用尾递归函数

时间:2017-11-09 23:21:48

标签: c recursion tail-recursion

我试图编写像这样定义的Hofstadter序列的尾递归函数:

enter image description here

到目前为止,我已经能够编写一个递归函数,它不是尾递归的:

int f_h(int n)
{
    int h;
    if(n==0){
        return 0;
    }
    h = f_h(f_h(f_h(n-1)));

    return(n-h);
}

0 个答案:

没有答案
相关问题