Problem of the day
If you are asked to find the 7th prime number, it’ll be 17 because the first 7 prime numbers are 2, 3, 5, 7, 11, 13, 17.
Try to solve the problem in O(N).
The first line of input contains an integer 'Q' representing the number of the queries. Then the queries follow:
The first line of each query contains an integers ‘N’ representing the number of a prime number to be found.
For each query, return the Nth prime number.
Print the output of each query in a separate line.
You do not need to print anything; it has already been taken care of. Just implement the given function.
1 <= Q <= 100
1 <= N <= 10^4
Time Limit: 1 sec
3
5
2
1
11
3
2
For the first query, the prime numbers are [2, 3, 5, 7, 11]
For the second query, the prime numbers are [2, 3]
For the third query, the prime number is [2]
3
46
20
13
199
71
41