本文整理匯總了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")