N th prime number
Problem to find the n th prime number.
Example-1:
Input : n = 5 Output : 11 Explain : 5 th prime number is 11.
Example-2:
Input : n = 6 Output : 13 Explain : 6 th prime number 13.
Solution
from itertools import count n = 5 l = [] for i in count(2): for j in range(2,i): if(i % j == 0): break else: l.append(i) if(len(l) == n): break print(l[-1])
Output
11