PrateekLovesCandy

could you please help me with this code. I am unable to get what’s wrong. Answer is coming wrong. I am sharing my code.

@priyanshi.agarwal3405 Your code is not giving correct answer for the sample test case. You just have to store all prime numbers using Prime Sieve and then print the output accordingly. Sieve of Eratosthenes is explained well in a video in the number theory section of your course. Please refer that.

Refer this to check how to implement:

Hope this helps :slightly_smiling_face:

Sir, i have used prime sieve only to store all the prime nos but still it doesn’t work. Could you please see my code and tell where do i need to do the changes.

https://ide.codingblocks.com/s/158508 .

Also i saw the code you sent . in that n(MAX_SIZE) is taken to be 1000005 but i think since it is given in question that ans does not exceed 10^6 so shouldn’t we take n as 10^8 , as a prime no of 10^6 range lies within 10^8.?

It is given that the answer should not exceed 10^6. It means that the (n’th prime no)<(10^6) always. It should be clear from this that n will also be < 10^6. That is why n is taken as 1000005.
Also, in your code mistake is at line number 28. Replace it with primes[j]=0; and reduce value of MAX_Size to 1000005. Also avoid calling prime sieve function again and again for all the test cases as it will give Time Limit Exceed error. Please give a read the code which i sent and you will understand.

Okay, got it sir. Thank you so much for your help.