Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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
Comment

create prime number python

def prime_checker(number):
    is_prime = True
    for i in range(2, number):
        if number % i == 0:
            is_prime = False
    if is_prime:
        print("It's a prime number.")
    else:
        print("It's not a prime number.")

n = int(input("Check this number: "))
prime_checker(number=n)
Comment

PREVIOUS NEXT
Code Example
Python :: rename multiple pandas columns with list 
Python :: django template capitalize equivalent 
Python :: save matplotlib figure with base64 
Python :: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. 
Python :: remove commas from string python 
Python :: How do I mock an uploaded file in django? 
Python :: count similar values in list python 
Python :: set os environment variable python 
Python :: find root directory of jupyter notebook 
Python :: python get copied text 
Python :: random color python matplotlib 
Python :: reload all extensions discord.py 
Python :: tkinter python may not be configured for Tk 
Python :: age in days to age in years 
Python :: how to increase height of entry in tkinter 
Python :: how to convert month to number in python 
Python :: pick random entry in dict python 
Python :: business logic in django 
Python :: python web3 to wei 
Python :: python range for float 
Python :: python datetime yesterday 
Python :: cv2 image object to base64 string 
Python :: pyspark create empty dataframe 
Python :: tkinter center frame 
Python :: create pyspark session with hive support 
Python :: python pandas trim values in dataframe 
Python :: how to make a query for not none value in django 
Python :: how to know python bit version 
Python :: mnist fashion dataset 
Python :: skimage image read 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =