<body>
<script type="text/javascript">
// f s t
// 1 1 2 3 5 8 输出第n项
// f s t
var n=parseInt(prompt('input'));
var first=1,
second=1,
third;
if(n>2){
//for循环是控制轮数
for(var i=0;i<n-2;i++){
third=first+second;
first=second;
second=third;
}
document.write(third);
}else {
document.write(1);
}
</script>
</body>
for循环是控制轮数,轮数可通过规律找出。
n指第几个数
n=3时 要进行1次
n=4时 要进行2次
n=5时 要进行3次
…
n=n时 要进行n-2次