c#斐波那契数列(Fibonacci)(递归,非递归)

 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));
        }     

posted @ 2015-04-13 15:42  不习惯打伞的鱼  阅读(303)  评论(0编辑  收藏  举报