# Programmer: Sriram Pemmaraju # Date: Jan 30th, 2015 # This program reads a positive integer, greater than 1 and # determines whether this integer is a prime or not. import math N = int(input("Please type a positive integer, greater than 1: ")) n = 2 # n will take on values from 2 through N and we will test each n for primality while n <= N: factor = 2 # initial value of possible factor isPrime = True # variable to remember if n is a prime or not factorUpperBound = math.sqrt(n) # the largest possible factor we need to test is sqrt(n) # loop to generate and test all possible factors while (factor <= factorUpperBound): # test if n is evenly divisible by factor if (n % factor == 0): isPrime = False break factor = factor + 1 # Output if isPrime: print(n) n = n + 1