HOMEWORK-python-2019-04-01

Print all of prime number within 100

import math

import datetime

start = datetime.datetime.now()

lst0=[]

for i in range(2,100):

    for j in lst0:

        if i % j == 0:

            break

        if j > math.sqrt(i):

            lst0.append(i)

            break

    else:

        lst0.append(i)

end = datetime.datetime.now()

delta =end-start

print(len(lst0))

#print(lst0)

print(delta.seconds)

你可能感兴趣的:(HOMEWORK-python-2019-04-01)