35 lines
637 B
Python
35 lines
637 B
Python
# coding=utf8
|
|
|
|
prime = []
|
|
total = 0
|
|
n = 2
|
|
|
|
def factor(x):
|
|
x = int(x)
|
|
if x <= 1: return 0
|
|
else:
|
|
for i in xrange(2, int(x ** 0.5) + 1):
|
|
if x % i == 0: break
|
|
else: return x
|
|
return i
|
|
|
|
while total <= 1000000:
|
|
if factor(n) == n:
|
|
total += n
|
|
prime.append(n)
|
|
n += 1
|
|
|
|
def search():
|
|
for length in xrange(len(prime) - 1, 2, -1):
|
|
for start in xrange(0, len(prime) - length + 1):
|
|
sump = 0
|
|
for tmp in prime[start: start + length]:
|
|
sump += tmp
|
|
if factor(sump) == sump:
|
|
print sump
|
|
print prime[start: start + length]
|
|
return 0
|
|
|
|
if __name__ == '__main__':
|
|
search()
|