Prime Visits test case failed

I have used the concept of the sieve of erasthones but still, I am getting the wrong answer. My code link is given below
https://ide.codingblocks.com/s/72010

Hi Dhiraj, your code is treating 0 as a prime number it is causing the problem. Just mark prime[0] as false or put

… && i != 0…

in loop in line 26

I recommend to write prime[0] = false & prime[1] = false after memset for everytime you write a seive code and NOT using (i!=1 && i!=0) in while loop.

Your code will pass all testcases after making this change. :slight_smile:

1 Like

thanks for your help