hw10_06_progression sum.html 379 B

12345678910111213141516
  1. <head>array fill</head>
  2. <body>
  3. <script>
  4. let i = 0;
  5. const arr = [];
  6. let x = 1;
  7. let n = +prompt("введите кол-во членов прогрессии N");
  8. for (; i < n; i++) {
  9. x = x + 3;
  10. arr.push(x);
  11. }
  12. result = ((2 * 1) + 3 * (n - 1)) / 2 * n;
  13. alert(result);
  14. </script>
  15. </body>