I read that every prime number is of the form $6k\pm1$, is this a correct approach to find out if a number is prime?
auto isPrime = [&](int num) {
if (num == 0 || num == 1)
return false;
if (num == 2 || num == 3)
return true;
if ((num - 1) % 6 == 0 || (num + 1) % 6 == 0)
return true;
else
return false;
};
That is if "prime" then "of the form $6k\pm 1$."
However, what you seem to implement is more the converse or even an if and only if.
– quid Jun 06 '16 at 15:37