Again I have tried to move on to another program and I am running into another snag. I am trying to write a program that determines if a number is prime. I know the basic format of what I have is pretty close (we talked about it in class), so I would not like to change it too much if at all possible. I cannot seem to get the program to run, it keeps giving me different error messages when I change things around. As usual any help would be most appreciated. THANKS Here is what I have come up with:
import math
def isprime(n):
print "This program determines if a given number is a prime number\
and will give True if it is and False if it is not."
if n < 2:
return False
elif n == 2:
return True
else:
for x in range(3, int(math.sqrt(n) + 1), 2):
if n % x == 0:
return False
return True
isprime()