A number that is divisible only by itself and 1 is called prime number.
In this program we will print next prime number and input will be taken from user.
def nextprime(n): while True: n+=1 for i in range(2,n): if n%i==0: break else: return n
Output: nextprime(11) 13
Follow us on Instagram @programmersdoor
Join us on Telegram @programmersdoor
Please write comments if you find any bug in above code/algorithm, or find other ways to solve the same problem.
Follow Programmers Door for more.