Given an integer N. The task is to find the next prime number i.e. the smallest prime number greater than N.
Examples:
Input: N = 10
Output: 11
11 is the smallest prime number greater than 10.
Input: N = 0
Output: 2
Approach:
- First of all, take a boolean variable found and initialize 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 until you will get the next prime number.
Below is the implementation of the above approach: