Answers for "next prime number in python"

1

next prime number in python

#add this code to your code and call "nextprime(number)"
def nextprime(n):
	prime=0
	n+=1
	for i in range(2,int(n**0.5)+2):
		if n%i==0:
			prime=0
			break
		else:
			prime=1
	if prime==1:
		print(n)
		return
	else:
		nextprime(n)
		return
Posted by: Guest on July-23-2021

Python Answers by Framework

Browse Popular Code Answers by Language