Given an integer N. The task is to find the Nth prime number.
Input : 5
Output : 11
Input : 16
Output : 53
Input : 1049
Output : 8377
- Find the prime numbers upto MAX_SIZE using Sieve of Eratosthenes.
- Store all primes in a vector.
- For a given number N, return element at (N-1)th index in a vector.
Below is the implementation of the above approach:
5th prime number is 11 16th prime number is 53 1049th prime number is 8377
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- New Algorithm to Generate Prime Numbers from 1 to Nth Number
- Find coordinates of a prime number in a Prime Spiral
- Program to find last two digits of Nth Fibonacci number
- Program to find the nth Kynea number
- Program to find the Nth Harmonic Number
- Program to find the Nth number of the series 2, 10, 24, 44, 70.....
- Program to find Nth odd Fibonacci Number
- Quick ways to check for Prime and find next Prime in Java
- Find Nth number in a sequence which is not a multiple of a given number
- Print the nearest prime number formed by adding prime numbers to N
- Check if a prime number can be expressed as sum of two Prime Numbers
- Count occurrences of a prime number in the prime factorization of every element from the given range
- Check if a number is Prime, Semi-Prime or Composite for very large numbers
- Count numbers in a given range whose count of prime factors is a Prime Number
- Program to find Nth term in the given Series
- Program to find the Nth term of the series 3, 7, 13, 21, 31.....
- Program to find the Nth term of series -1, 2, 11, 26, 47......
- Program to find Nth term of series 9, 23, 45, 75, 113...
- Program to find Nth term in the series 0, 2, 1, 3, 1, 5, 2, 7, 3,…
- Program to find the Nth term of the series 3, 20, 63, 144, 230, ……
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : ihritik