Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Tania Skichko
- // zero.p2p.shpp.me/tasks/3_2_numbers.html
- // pastebin.com/A9geirEm - перше виконання
- //pastebin.com/38Q09Dv4 - рев'ю
- // 1. вивести на екран числа від 1 до N (де N - це число, яке введе користувач).
- let yournumber = +prompt("Введіть число");
- let x = 1;
- for (; x <= yournumber; x++) {
- console.put(x + (x < yournumber ? "," : " "));
- }
- // 2. Використовувати while для задачі
- let yournumber = +prompt("Введіть число");
- let x = 1;
- while (x <= yournumber) {
- console.put(x + (x < yournumber ? "," : " "));
- x++;
- }
- // 3. Вивести в зворотньому порядку числа
- let yournumber = +prompt("Введіть число");
- for (let x = 1; yournumber >= x; yournumber--) {
- console.put(yournumber + (yournumber > x ? ",": " "));
- }
- // 4. Вивести на екран парні числа от 2 до N
- let yournumber = +prompt("Введіть число");
- for (let x = 2; x <= yournumber; x++) {
- if (yournumber % 2 == 1) continue;
- console.put(x + (x < yournumber ? "," : ""));
- }
Advertisement
Add Comment
Please, Sign In to add comment