[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!'
除非特別註明,本頁內容採用以下授權方式: Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License