#coding:utf-8
defgetPrime(maxNum):#网上抄了一个解决方案,定义一个函数:
aList = [xforxinrange(0, maxNum)]#一个列表式生成aList
prime = []
foriinrange(2,len(aList)):
ifaList[i] !=0:
prime.append(aList[i])
clear(aList[i], aList, maxNum)
returnprime
defclear(aPrime, aList, maxNum):
foriinrange(2,int((maxNum / aPrime) +1)):
if notaPrime * i > maxNum -1:
aList[i * aPrime] =0
print(getPrime(100))
话说,第二个循环就看不懂了。。。。哎!数学太差
听了微信上各个同学的发言,感觉天南地北的,各种背景,好神奇呀
网友评论