#t494. 第 n 小的质数

第 n 小的质数

The n-th Smallest Prime

Problem Description

Given a positive integer nn, find the nn-th smallest prime number.

Input Format

One positive integer nn not exceeding 1000010000.

Output Format

The nn-th smallest prime number.

Sample Input

10

Sample Output

29

Constraints

1≤n≤100001 \le n \le 10000.

Hint

  • The primes in order are 2,3,5,7,11,13,17,19,23,29,…2, 3, 5, 7, 11, 13, 17, 19, 23, 29, \dots; the 1010-th is 2929.
  • Generate primes (a simple primality test up to a few hundred thousand is fast enough) and stop at the nn-th one.