How to we get idea about what would be the 10^5th prime number?
Playing with Cards
@ap8730390
you can create a queue and keep on adding all the prime numbers from the starts and do the following operations
let me explain you the sample test case with q=3
.5 3
3 4 7 6 5
after 1st iteration (1st prime no is 2)
A1->5,7,3
B1->6,4
now 2 nd iteration (2 nd prime no is 3)
A2->7,5
B2->3
now 3 rd iteration ( 3 rd prime no is 5)
A3->7
B3->5
Output numbers on these cards from top to bottom of each piles in order of B1, B2, B3,A3.
No, actually my doubt is how to find what could be the 100000th prime number?
@ap8730390
1,299,709 is the 100000th prime number so you either use iterative or sieve of eratosthenes to solve this.
In iterative method you can do the following
int ct=0;
int x=2;
while(ct<10000){
if(isPrime(x)){
ct++;
}
x++;
}
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.