i need some help please !! this is the code i founded in data-strucure book i understand that t all primes are of the form 6k ± 1, with the exception of 2 and 3 where k is some integer. the problem is in the for loop why we add 6 to i (i+6) and this condition in if statment if (n%i == 0 || n%(i+2) == 0):
function isPrime(n){
if (n <= 1) return false;
if (n <= 3) return true;
// This is checked so that we can skip
// middle five numbers in below loop
if (n%2 == 0 || n%3 == 0) return false;
for (var i=5; i*i<=n; i=i+6){
if (n%i == 0 || n%(i+2) == 0)
return false;
}
return true;
}