题解 | 判断质数
判断质数
https://www.nowcoder.com/practice/b936f737e2b34b3199a7c875446edd06
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
</head>
<body>
<script type="text/javascript">
// 补全代码
// 质数(Prime Number),又称素数,是指在大于 1 的自然数中,除了 1 和它本身以外,不能被其他自然数整除的数。
Number.prototype._isPrime = function() {
if (this <= 1) return false;
for (let i = 2; i < this; i++) {
if (this % i === 0) {
return false;
}
}
return true;
}
console.log((2).isPrime());
</script>
</body>
</html>

