导航

C#递归算法

Posted on 2018-01-30 17:37  清浅ヾ  阅读(238)  评论(0编辑  收藏  举报
public static int fun(int i)
{
    if (i<=0)
    {
        return 0;
    }
    else if (i>0&&i<=2)
    {
        return 1;
    }
    else
    {
        return fun(i - 1) + fun(i - 2);
    }
}

//直接调用fun(8)