let max = process.argv[2]; for(cnt = 3; cnt <= max; cnt += 2) { let sq = Math.round(Math.sqrt(cnt)); let isPrime = true; for(i=3; i<=sq; i+=2) { if(cnt % i == 0) { isPrime = false break; } } if (isPrime) { console.log(cnt); } }