Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

prime numbers up to 100

List of prime numbers from 1-100:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
Comment

prime numbers 1 to 100

for i in range(101): #range can be changed upto any positive integer
       j=2    #j is the divider  
       while i%j!=0 or i==2:  #checking if (i/j) gives a remainder, 
                              #also if i=2, the loop still runs or else 2 is not considered a prime
              j+=1  #increasing j by 1
              if j>i/2:  #check only dividers(j) of i upto i/2 cause above that ur just reapeating the same factors
                     print(i,'is a prime')
                     break  #breaks while loop
Comment

prime numbers up to 100

List of prime numbers from 1-100:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
Comment

prime numbers 1 to 100

for i in range(101): #range can be changed upto any positive integer
       j=2    #j is the divider  
       while i%j!=0 or i==2:  #checking if (i/j) gives a remainder, 
                              #also if i=2, the loop still runs or else 2 is not considered a prime
              j+=1  #increasing j by 1
              if j>i/2:  #check only dividers(j) of i upto i/2 cause above that ur just reapeating the same factors
                     print(i,'is a prime')
                     break  #breaks while loop
Comment

PREVIOUS NEXT
Code Example
Python :: how to sort nested list in python 
Python :: Python list tutorial for beginners 
Python :: python fme logger 
Python :: formatting strings in python 
Python :: corpus 
Python :: import os python 
Python :: delete function python 
Python :: How to select element using xpath in python 
Python :: python conditional statement 
Python :: characters python 
Python :: python how to find the highest even in a list 
Python :: IndexError: list assignment index out of range 
Python :: matplotlib subplots share x axis 
Python :: pine script to python 
Python :: np.random.randint 
Python :: initialize 2d array of zeros python 
Python :: pytest-mock tutorial 
Python :: hide password in python 
Python :: using comma as the thousand separator 
Python :: python function to do comparison between two numbers 
Python :: python3 delete file 
Python :: python dataframe find no of true 
Python :: compare two excel files using python pandas 
Python :: Python NumPy column_stack Function Syntax 
Python :: django connexion session time 
Python :: to text pandas 
Python :: python schleife 
Python :: This code is supposed to display "2 + 2 = 4" on the screen, but there is an error. Find the error in the code and fix it, so that the output is correct. 
Python :: c is better than python 
Python :: how to print 2d neatly in python 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =