1 public class MainClass 2 { 3 public static void Main() 4 { 5 Console.WriteLine(Foo(30)); 6 } 7 public static int Foo(int i) 8 { 9 if (i <= 0) 10 return 0; 11 else if(i > 0 && i <= 2) 12 return 1; 13 else return Foo(i -1) + Foo(i - 2); 14 } 15 }
1 public class MainClass 2 { 3 public static void Main() 4 { 5 Console.WriteLine(Foo(30)); 6 } 7 public static int Foo(int i) 8 { 9 if (i <= 0) 10 return 0; 11 else if(i > 0 && i <= 2) 12 return 1; 13 else return Foo(i -1) + Foo(i - 2); 14 } 15 }
转载于:https://www.cnblogs.com/myBlogOu/p/9940059.html