public static void main(String[] args) {
int Num = 1;
for(int i = 1 ; i < 20 ; i++){
Num = getNum(i);
System.out.println("鸽子第 "+i+" 个月的总数为:"+Num);
}
}
public static int getNum(int x){
int num= 1;
if(x == 1 || x == 2){
return num;
}
num= getNum(x-1) + getNum(x-2);
return num;
} |