Close
Topic list
Find Nth Prime
MEDIUM
15 mins
Other topics
Problem solved
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Find Nth Prime

Contributed by
Dhruv Sharma
Medium
0/80
Avg time to solve 15 mins
Success Rate 85 %
Share

## Problem Statement

#### For example:-

``````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.
``````

#### Note: 1 is not a prime number.

``````Try to solve the problem in O(N).
``````
Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### Sample Input 1:
``````3
5
2
1
``````
##### Sample Output 1:
``````11
3
2
``````
##### Explanation for sample input 1:
``````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]
``````
##### Sample Input 2:
``````3
46
20
13
``````
##### Sample Output 2:
``````199
71
41
``````
Auto
Console