Initial commit
This commit is contained in:
19
problem-50.py
Normal file
19
problem-50.py
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
from primes import sieve, is_prime
|
||||
from copy import deepcopy
|
||||
|
||||
if __name__ == '__main__':
|
||||
primes = list(sieve(1000005))
|
||||
longest = []
|
||||
total = 0
|
||||
chain = []
|
||||
for idx, prime in enumerate(primes):
|
||||
chain = [prime]
|
||||
total = sum(chain)
|
||||
while total < 1000000:
|
||||
if is_prime(total) and len(chain) > len(longest):
|
||||
longest = deepcopy(chain)
|
||||
chain.append(primes[idx+len(chain)])
|
||||
total = sum(chain)
|
||||
print(longest, len(longest), sum(longest))
|
||||
|
||||
Reference in New Issue
Block a user