本文整理汇总了Python中Euler.primeSieve方法的典型用法代码示例。如果您正苦于以下问题:Python Euler.primeSieve方法的具体用法?Python Euler.primeSieve怎么用?Python Euler.primeSieve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Euler
的用法示例。
在下文中一共展示了Euler.primeSieve方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: len
# 需要导入模块: import Euler [as 别名]
# 或者: from Euler import primeSieve [as 别名]
# Problem 50: Consecutive Prime Sum
import time
t1 = time.clock()
import Euler
limit = 4000
primes = [x for x in Euler.primeSieve(limit)]
answer = [(0,[])]
for x, prime1 in enumerate(primes):
startprime = x
sequence = []
counter = 0
for y, prime2 in enumerate(primes):
if y >= x:
counter += prime2
if Euler.isPrime(counter) == True:
if counter < 1000000:
sequentials = [x for x in primes[x:y+1]]
if len(answer[0][1]) < len(sequentials):
answer[0] = ((counter, sequentials))
print("Prime = " + str(answer[0][0]) + " ; Length of sequence: " + str(len(answer[0][1])))
print("Sequence start = " + str(answer[0][1][0]) + " ; Sequence end = " + str(answer[0][1][-1]))
t2 = time.clock()
print("Runtime = " + str(t2-t1)[:4] + " seconds")