Problem 548
Nth Prime
Problem
Print the N-th prime number, counting from 2 as the first prime. The 100000-th prime is 1299709, so a sieve of Eratosthenes up to about 1.3 million is enough. Mark every multiple of each prime as composite, then walk through the numbers that are still unmarked and stop at the N-th one. Trial division of every number would be much slower.
Input
A single integer N.
Output
Print the N-th prime number.
Constraints
1 <= N <= 100000
Example input
10
Example output
29
Explanation
The primes in order are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, ... The tenth one in this list is 29, so for N = 10 the answer is 29.