程序分析: 兔子的规律为数列 1,1,2,3,5,8,13,21....
每月兔子数:1,1,4,6,10,16,26,42....
var num1=1;
var num2=0;
var sum=0;
var mon=prompt('输入兔子的数量','1');
if(isNaN(mon)==true){
mon=parseInt(mon);
}else{
mon=parseInt(mon)
}
for(i=1;i<=mon;i++){
if(i%2!=0){
sum=num1+num2;
num1=sum;
}else{
sum=num1+num2;
num2=sum;
}
}
alert(2*sum);