Hello

I am trying to write a program that will figure out if a number is prime
or not. Currently this is the code that I have:

import math

def main():

    number=input("Please enter a positive whole number greater than 2: ")
    for value in range(2, number-math.sqrt):
        if number % value == 0:
            print number, "is not prime"
            exit
    print number, "is prime"

main()

my problem is that the output prints both statements whether the number is
prime or not. How could I get it to only print the one statement saying
that 49 is not a prime number?

enter a number greater than 2: 49
49 is not prime
49 is prime



_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to