#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jun 20 14:29:24 2023 @author: richardson """ def isitprime2(nn): for j in range(2,nn): # range(2,nn) means the integers 2,3,4,...,lastj-1 # each time through the loop, j becomes 2, # then 3, then 4, ... # and the loop is run lastj-2 times. if nn%j==0: # need two = signs if you are #checking if an equation is true are not. # a==b means True if a=b, False # if a!=b. '!=' means not equal. # nn%j means nn mod j = remainder # when nn is divided by j. return False return True print("To make a list of all primes less than a certain number:") print("We'll use a for loop") print(' ') print('We will calculate the list of all primes less than N') print('Please give us N:') N = int(input()) # \n means line feed # \r means carriage return plist=[] for j in range(2,N): if isitprime2(j): plist+=[j] print("Here is the list:") print(plist) print("To make a list of the first N primes") print("We'll use a while loop") print(' ') print('We will calculate the list of the first N primes') print('Please give us N:') N = int(input()) # \n means line feed # \r means carriage return plist=[] j=2 while len(plist)