<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
//著名的斐波那契额数列1 1 2 3 5 8输出第n项;
<script type = "text/javascript">
var n = parseInt(window.prompt('input'));
var first = 1,
second = 1,
third;
if(n>2){
for(var i = 0;i < n - 2;i ++ ){
third = first + second;
first = second;
second = third;
}
document.write(third);
}else{
document.write(1);
}
</script>
</body>
</html>
//著名的斐波那契额数列1 1 2 3 5 8输出第n项;
最新推荐文章于 2023-12-02 16:50:56 发布