TaniaS93

03.08.21 Tania Skichko - Task 3.2 Numbers EDIT

Aug 3rd, 2021
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Tania Skichko
  2. // zero.p2p.shpp.me/tasks/3_2_numbers.html
  3.  
  4. // pastebin.com/A9geirEm - перше виконання
  5. //pastebin.com/38Q09Dv4 - рев'ю
  6.  
  7. // 1. вивести на екран числа від 1 до N (де N - це число, яке введе користувач).
  8. let yournumber = +prompt("Введіть число");
  9. let x = 1;
  10. for (; x <= yournumber; x++) {
  11.     console.put(x + (x < yournumber ? "," : " "));
  12. }
  13.  
  14. // 2. Використовувати while для задачі
  15. let yournumber = +prompt("Введіть число");
  16. let x = 1;
  17. while (x <= yournumber) {
  18.     console.put(x + (x < yournumber ? "," : " "));
  19.     x++;
  20. }
  21.  
  22. // 3. Вивести в зворотньому порядку числа
  23. let yournumber = +prompt("Введіть число");
  24. for (let x = 1; yournumber >= x; yournumber--) {
  25.     console.put(yournumber + (yournumber > x ? ",": " "));
  26.     }
  27.  
  28. // 4. Вивести на екран парні числа от 2 до N
  29. let yournumber = +prompt("Введіть число");
  30. for (let x = 2; x <= yournumber; x++) {
  31.     if (yournumber % 2 == 1) continue;
  32.     console.put(x + (x < yournumber ? "," : ""));
  33. }
  34.  
  35.  
Advertisement
Add Comment
Please, Sign In to add comment