I have a minor question about the following function on StackOverflow.com stackoverflow prime number function. Given as reference by freeCodecamp to help solve this algorithm Sum of all Primes. Can any one please explain why number 2 is true when passed into this function isPrime.
function isPrime(num) {
if(num < 2) return false;
for (var i = 2; i < num; i++) {
if(num%i==0)
return false;
}
return true;
}
How can number 2(num) be true(prime) when the for loop starts from 2 . And 2 modulus(%) 2 equals 0.
It should return false?.