Python爬虫作业

20170522-Python作业

2017-05-22  本文已影响73人  Jerome_vae

##  求素数

# By 威威

# 20170522

primeList = [1]

for i in range(2, 101):

for j in range(2, i+1):

if i%j == 0:

count = j

if count != i:

break

else:

primeList.append(i)

break

else:

continue

print(primeList)

得到的结果是:

[1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

啦啦啦啦

上一篇下一篇

猜你喜欢

热点阅读