要求用控制台应用程序写出如下1,1,2,3,5,8,13,21,34,55,89...

当时没想开,今天调试一下出来了结果

如下

class Program
    {
        static void Main(string[] args)
        {
            Num(0, 1,1, 30);
            Console.ReadLine();
        }

        private static int Num(int num, int s, int level, int count)
        {
            Console.Write("{0},", s);
            if (level < count)
            {
                num = Num(s, (s + num), ++level, count);
            }
            return num;
        }
    }

posted on 2012-09-05 13:05  tnspop  阅读(178)  评论(0编辑  收藏  举报