In JavaScript, how would I generate 100 random numbers and display the results of checking each one for primality, if I'm using a Boolean function named isPrime which then takes an integer as an argument and returns true if the argument is a prime number of false? For some reason I am stuck..
So far I have this:
function isPrime(number) {
var start = 2;
while (start <= Math.sqrt(number)) {
if (number % start++ < 1) return false;
}
return number > 1;
}
Aucun commentaire:
Enregistrer un commentaire