用递归计算斐波那契数列(1,1,2,3,5,8,11)(附时间复杂度

本文为作者原创,欢迎转载并注明原出处,如果本文对您有帮助,请您关注、评论或点赞,感谢您的支持!
本文链接: https://blog.csdn.net/kkkksc03/article/details/102291343
int f(int x)
    {
 
        if (x <= 0)
        {
            return 0;
        }
        if (x == 1 || x == 2)
        {
            return 1;
        }
        return f(x - 2) + f(x - 1);
    }

O ( F n ) 时间复杂度O(F_n)

猜你喜欢

转载自blog.csdn.net/kkkksc03/article/details/102291343