File: class/Workbook/Examples/Lecture4/whileprime.txt

x = y / 2
while x > 1:
    if y % x == 0:                 # remainder
        print y, 'has factor', x
        break                      # skip else
    x = x-1
else:                              # normal exit
    print y, 'is prime'



[Home page] Books Code Blog Python Author Train Find ©M.Lutz