문제
풀이
let input = require('fs').readFileSync('/dev/stdin').toString().trim();
const isPrime = (n) => {
if (n === 1 || n === 0) return false;
if (n === 2) return true;
for (let i = 2; i <= Math.ceil(Math.sqrt(n)); i++) {
if (n % i === 0) {
return false;
}
}
return true;
};
const sol = (input) => {
let [lt, rt] = input.split(" ").map(Number);
const answer = [];
for (let i = lt; i <= rt; i++) {
if (isPrime(i)) {
answer.push(i);
}
}
return answer;
};
const ans = sol(input);
for (let x of ans) {
console.log(x);
}