# @Time : 2017/6/24 15:40
# @Author : wanyang
# @Mail :[email protected]
# @Question:https://projecteuler.net/problem=7
# @Answer :
# 初始化质数集合
primelist = [2]
# 筛选质数规则:常数从3开始和质数集合中的每一个数字进行取余运算,若都不能整除,则该数字为质数并添加到集合中;反正则重新开始循环
primecount = 10001 # 集合的大小
index = 0
num = 3
while index < primecount - 1:
flag = True
for i in primelist:
if num % i == 0:
flag = False
break
if flag:
index = index + 1
primelist.append(num)
print("第%d个质数:%d" % (index, num))
# 偶数过滤
num = num + 2