home
search
help
profile
liking the experience? our app is even better
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now  
showing results for how to find prime numbers c 2b 2b
1// 6k+-1 optimisation
2bool is_prime6(int num) {
3  int i;
4  if (num == 1)
5    return false;
6  if (num <= 3)
7    return true;
8  if (num % 2 == 0 || num % 3 == 0)
9    return false;
10  if (num < 25)
11    return true;
12  for (i = 5; i * i <= num; i += 6)
13    if (num % i == 0 || num % (i + 2) == 0)
14      return false;
15  return true;
16}
upvote
downvote