递归的基本练习

        做梦N层
        static void Main(string[] args)
        {
            Test(1);
        }
        static void Test(int n)
        {
            if (n > 10)
            {
                return;
            }
            Console.WriteLine("正在做第{0}层梦", n);
            Test(n + 1);
            Console.WriteLine("第{0}层梦醒了", n);
        }

猴子吃桃子,每天吃一半然后扔掉一个,问第一天有多少

        static void main(string[] args)
        {
            program hanshu = new program();
            int a = taozi(1);
            console.writeline(a);
        }
        static int taozi(int day)
        {
            if (day == 7)
            {
                return 1;
            }
            int n = (taozi(day + 1) + 1) * 2;
            return n;
        }

原文地址:https://www.cnblogs.com/UC0079/p/5491759.html