[Python]列出質數

列出質數:

start = int(raw_input("Enter the start point(1-1000):"))
end = int(raw_input("Enter the end point(1-1000):"))
 
def cl(x):return x==2 or x==3 or x==5 or x==7 or (x%2!=0 and x%3!=0 and x%5!=0 and x%7!=0)
 
a = filter(cl,range(start,end))
 
if(start < end):
    for i in a:
        print i
else:
    print 'Argument Error!'
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License