Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const input = ['24'];
- const print = this.print || console.log;
- const gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
- const n = +gets();
- let primes = [];
- primes.push(1);
- primes.push(2);
- for (let i = 3; i <= n; i++) {
- primes.push(i);
- for(let j = 2; j < i; j++) {
- if(i % j == 0) {
- primes.pop();
- break;
- }
- }
- }
- print(primes.join(' '));
Advertisement
Add Comment
Please, Sign In to add comment