Tuesday 15 June 2010

python - My program is not printing out the message I want -



python - My program is not printing out the message I want -

i have written prime number programme , i'm having problem printing out message "neither prime nor composite" below. think code fine is. i'd highly appreciate comment on issue. give thanks you, in advance

def prime_number(): = input("please come in number:") x = true s = 0 in range(2, a): while x: if a%i == 0: x = false elif s: print s,"neither prime nor composite" else: x = true if x: print a,"is prime number." elif s: print s,"neither prime nor composite" else: print a,"is not prime number." prime_number()

your variable s remain equall 0 equall false forever, there no way code going print "neither prime nor composite"

python python-2.7 primes

No comments:

Post a Comment