练习27_斐波那契数列倒叙输出.html 571 B

123456789101112131415161718192021222324
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. </head>
  8. <body>
  9. <script>
  10. var arr = [1,1];
  11. for(var i=3;i<=40;i++){
  12. arr.push(arr[i-2]+arr[i-3])
  13. }
  14. arr = arr.reverse();
  15. console.log(arr);
  16. arr.forEach(function(item,index){
  17. document.write(item+"&nbsp;");
  18. if((index+1)%6==0){
  19. document.write("<br>");
  20. }
  21. })
  22. </script>
  23. </body>
  24. </html>