Problem 196582 · medium · Level 01 Prerequisites & Setup

The n-th Prime

functions · primes · loops

Write nth_prime(n) that returns the n-th prime number, counting from 2 as the 1st.

Examples

Input:  n = 1
Output: 2

Input:  n = 6
Output: 13

Input:  n = 100
Output: 541

Constraints

  • 1 <= n <= 2000

Goals

  • Reuse a prime test inside a search loop
  • Count matches until the n-th one appears
Starting Python…