Prime visits problem

i am getting segmentation error in my code :https://ide.codingblocks.com/s/223860

previous code is not complete so this is my another code:https://ide.codingblocks.com/s/223860

hello @souravkhan654
a) u can not a very large size array due to memory constraint. for this problem sieve of size 10^6+1 will work .
b) dont compute sieve again n again it will give tle.
refer this video editorial by prateek bhaiya ->

https://www.youtube.com/watch?v=8sniiDbfPK4