数学趣题——兔子产仔问题

Fi = 1 (i =1), 2(i = 2), Fi-1 + F i-2 (i >= 3)

   1: #include <stdio.h>
   2:  
   3: int Fib(int n)
   4: {
   5:     if (n == 1 || n == 2)
   6:         return 1;
   7:     else
   8:         return Fib(n-1) + Fib(n-2);
   9: }
  10:  
  11: int main()
  12: {
  13:     printf("one year the are %d pairs of rabbits\n", Fib(12));
  14:     return 0;
  15: }

你可能感兴趣的:(问题)