Wednesday, July 8, 2015

Prime Number



def is_prime(a):
    x = True
    for i in range(2, a):
       if a%i == 0:
           x = False
           break # ends the for loop
       # no else block because it does nothing ...


    if x:
        print "prime"
    else:
        print "not prime"

No comments:

Post a Comment