<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<p>斐波那契数列:1,1,2,3,5,8,13,21,34,55,89,144........... </p>
<p>求斐波那契数列第n项的值</p>
</body>
<script type="text/javascript">
var n = prompt("请输入数字n")
var num1 = 1;
var num2 = 1;
for(var i = 3; i <= n; i++) {
var temp = num2;
num2 = num1 + num2;
num1 = temp;
}
alert(num2);
</script>
</html>