6 lines
183 B
JavaScript
6 lines
183 B
JavaScript
const isPrime = num => {
|
|
const boundary = Math.floor(Math.sqrt(num));
|
|
for (var i = 2; i <= boundary; i++) if (num % i == 0) return false;
|
|
return num >= 2;
|
|
};
|
|
module.exports = isPrime |