综合练习3编程题5.html 528 B

12345678910111213141516171819202122232425
  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. // 定一个计算 n的阶层的函数
  11. function factorial(n){
  12. var res = 1;
  13. for(var i=1;i<=n;i++){
  14. // res = res * i;
  15. res *= i;
  16. }
  17. return res;
  18. }
  19. console.log(factorial(12) - factorial(10));
  20. </script>
  21. </body>
  22. </html>