有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第四个月后每个月又生一对兔子,假如兔子都不 死,问每个月的兔子总数为多少?

题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第四个月后每个月又生一对兔子,假如兔子都不
死,问每个月的兔子总数为多少?
1.程序分析: 兔子的规律为数列1,1,2,3,5,8,13,21....

 1 public class Algorithm_Game_01 {
 2     
 3     public static void main(String[] args) {
 4         int month = 20;
 5         for(int i = 1 ; i < month ; i ++){
 6             System.out.print(f(i)+"=>");
 7         }
 8     }
 9     public static int f(int  n){
10         if(n==1||n==2)return 1;
11         else{
12             return f(n-1)+f(n-2);
13         }
14     }
15 
16 }