Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Problem 1. Numbers from 1 to N
- //
- // Write a program that enters from the console a positive integer n and prints all the numbers
- // from 1 to n, on a single line, separated by a space.
- //
- // Examples:
- // n output
- // 3 1 2 3
- // 5 1 2 3 4 5
- let input = ['5'];
- let print = this.print || console.log;
- let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
- let num = Number(gets());
- let result = ''; // create counter variable
- for(let i = 1; i <= num; ++i ){
- result += i + ' ';
- }
- console.log(result);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement