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