【Python】求素数-未经过任何优化

print 'Find prime number smaller then  input number 
'
print 'Please input a number:'
import time
number=raw_input()
num=1
end=[]
b=0
n=0
while num<int(number):
    div=1
    while div<num:
        result=float(num)/div
        if float(result).is_integer():
            n+=1
        div+=1
    if n==1:
        end.append(num)
    num+=1
    n=0
print "The prime number smaller then %s are:
" % str(number)
print end
print "The calculate spend %.8f second" % time.clock()
raw_input()
原文地址:https://www.cnblogs.com/colipso/p/3265917.html