C#斐波那契数列递归算法

时间:2017-08-05 19:24:53   收藏:0   阅读:250

 public static int Foo(int i)
        {
            if (i < 3)
            {
                return 1;
            }
            else
            {
                return Foo(i - 1) + Foo(i - 2);
            }
        }

        static void Main(string[] args)
        {
            Console.WriteLine(Foo(8));
        }     

原文:http://www.cnblogs.com/was231310/p/7291042.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!