在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
static void Main() { Console.WriteLine("P(n) n equal 0:"); Console.WriteLine("result:{0}", P(0)); Console.WriteLine("P(n) n equal 1:"); Console.WriteLine("result:{0}", P(1)); Console.WriteLine("P(n) n equal 2:"); Console.WriteLine("result:{0}", P(2)); Console.WriteLine("P(n) n equal 3:"); Console.WriteLine("result:{0}", P(3)); Console.WriteLine("P(n) n equal 4:"); Console.WriteLine("result:{0}", P(4)); Console.ReadKey(); } private static int P(int n)//n=4,3,2,1,0 { Console.WriteLine("test n values:{0}", n);//4,3,2,1,0,1,2,3,4 if (n == 0) return 1; else return n * P(n - 1);//4*P(3) 3*P(2) 2*P(1) 1*P(0) } http://C:\Users\lenovo\Desktop\P.jpg test result: P(n) n equal 0: |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论