function isPrime(n){ if(n < 2) return false; for(var i = 2 ; i < n ; i++){ if(n % i === 0) return false; } return true; } var primeList = [-1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].filter(isPrime); console.log(primeList);
function isPrime(n){ if(n < 2) return false; for(var i = 2 ; i < n ; i++){ if(n % i === 0) return false; } return true; } var primeList = [-1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].filter(isPrime); console.log(primeList);
Comments
Post a Comment