Deepak and Primes

https://ide.codingblocks.com/s/28336 in this code i am not understanding what is happening here
while(N && counter<100000000)
{
counter++;
if(!sieve[counter])
N–;
}
cout<<counter;
}

It calculates nth prime number

but kaise chal raha hai ye?
yahi samjh nahi aaya

First we calculate the prime numbers using sieve method. Then we run a while loop which decreases n by 1 if we encounter a prime. if n==0 the loop stops and we print nth prime then.


its not getting submitted can u tell me some other approach?

Try this:


still not getting submitted brother

Updated the code: