Given an integer N. The task is to find the next prime number i.e. the smallest prime number greater than N.
Input: N = 10
11 is the smallest prime number greater than 10.
Input: N = 0
- First of all, take a boolean variable found and initialise it to false.
- Now, until that variable not equals to true, increment N by 1 in each iteration and check whether it is prime or not.
- If it is prime then print it and change value of found variable to True. otherwise, iterate the loop untill you will get the next prime number.
Below is the implementation of the above approach:
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.
- Program to find the Nth Prime Number
- Find coordinates of a prime number in a Prime Spiral
- Program to find sum of prime numbers between 1 to n
- Program to find the LCM of two prime numbers
- C/C++ Program to find Prime Numbers between given range
- Program to find Prime Numbers Between given Interval
- C Program to Check Whether a Number is Prime or not
- Recursive program for prime number
- Find the minimum number to be added to N to make it a prime number
- Python program to check whether a number is Prime or not
- Efficient program to print all prime factors of a given number
- C Program for efficiently print all prime factors of a given number
- Given a number x , find y such that x*y + 1 is not a prime
- Java Program for efficiently print all prime factors of a given number
- Find the position of the given Prime Number
- Find largest prime factor of a number
- Find prime number K in an array such that (A[i] % K) is maximum
- Find all the prime numbers of given number of digits
- Find sum of a number and its maximum prime factor
- Analysis of Different Methods to find Prime Number in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.