JS——do...while循环输出斐波拉契数前20项

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script type="text/javascript">
document.write("第一题:输出前20项斐波拉契数:");
var a=1,b=1,c;
var i=1;
do{
c=a+b;
a=b;
b=c;
document.write(""+c+"--");
i++;
}
while(i<=20);


</script>
</body>
</html>

posted @ 2017-12-18 13:37  燕林夕  阅读(1150)  评论(0编辑  收藏  举报