<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="text/javascript">
var num1 = 1;
var num2 = 0;
var sum = 0;
var mon = prompt("请输入你所要计算兔子数量的月数:", "1");
if(isNaN(mon) == true){
mon = parseInt(prompt(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(mon + "月之后,兔子的数量为:" + 2 * sum);
</script>
</head>
<body>
</body>
</html>