Write a function named isPrime and pass a parameter n, if n is prime return true, else return false
function isPrime(n) {
if (n === 1) return false;
for (let i = 2; i < n; i++) {
if (n % i === 0) {
return false;
}
}
return true;
}
function isPrime(n) {
if (n === 1) return false;
for (let i = 2; i < Math.sqrt(n); i++) {
if (n % i === 0) {
return false;
}
}
return true;
}
console.log(isPrime(1));
console.log(isPrime(5));
console.log(isPrime(37));