blob: 07a4042345eb4c9dcbf9abe6f840b4399e65e93c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
|
function isPrime(n) {
if (n < 2 || n != Math.trunc(n))
return false;
for (let i = 2; i * i <= n; ++i)
if (n % i == 0)
return false;
return true;
}
if (!module.parent)
console.log(isPrime(Number(process.argv[2])) ? 'prime' : 'no prime');
|