Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

list of prime numbers in python

n = 20
primes = []

for i in range(2, n + 1):
	for j in range(2, int(i ** 0.5) + 1):
 		if i%j == 0:
 			break
	else:
		primes.append(i)

print(primes)
Comment

python list prime numbers

print([i for i in range(2, int(input("Enter your number: "))+1) if 0 not in [i%n for n in range(2, i)]])
Comment

PREVIOUS NEXT
Code Example
Python :: matplotlib show imaginary numbers 
Python :: compute difference between two images python opencv 
Python :: python import from other folder outside folder 
Python :: add all string elements in list python 
Python :: get local timezone python 
Python :: how to convert a list into a dataframe in python 
Python :: matplotlib grid in background 
Python :: draw spiral in matplotlib 
Python :: How do I mock an uploaded file in django? 
Python :: python merge pdfs 
Python :: order pandas dataframe by column values 
Python :: read csv python pandas plot 
Python :: add x axis label python 
Python :: Show the records that have nan values 
Python :: get sheet names using pandas 
Python :: python cmd colors 
Python :: matplotlib plot remove margins 
Python :: series datetime64 seconds to 0 
Python :: pytesseract pdf to text 
Python :: ipywidgets pip 
Python :: python remove read only file 
Python :: for e in p.event.get(): pygame.error: video system not initialized 
Python :: polynomial fit in python 
Python :: required validator python WTForms 
Python :: tkinter center frame 
Python :: postgres python 
Python :: Extract categorical data features 
Python :: py spam message 
Python :: sparksession pyspark 
Python :: pyqt5 wait cursor 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =