summaryrefslogtreecommitdiff
path: root/050.py
diff options
context:
space:
mode:
authorReiner Herrmann <reiner@reiner-h.de>2014-08-31 20:21:45 +0200
committerReiner Herrmann <reiner@reiner-h.de>2014-08-31 20:35:09 +0200
commit95341b61b030c9e1290f3b326cb7ec584f543aea (patch)
tree852386fa04d32eb859bca11c0eff7b5ef9e50f00 /050.py
parent571164d977f91925c4c76a292f74f5f93d09ae23 (diff)
moved files to higher directory after split to new repositoryHEADtrunk
Diffstat (limited to '050.py')
-rw-r--r--050.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/050.py b/050.py
new file mode 100644
index 0000000..615f0d5
--- /dev/null
+++ b/050.py
@@ -0,0 +1,28 @@
+from common import sieve
+
+limit = 1000000
+
+prime_set = sieve(limit).primes()
+prime_list = list(prime_set)
+prime_list.sort()
+
+n = len(prime_list)
+
+max_sum = 0
+max_count = 0
+
+for i in xrange(n):
+ sum = prime_list[i]
+ count = 1
+ for j in xrange(i+1, n):
+ sum += prime_list[j]
+ count += 1
+ if sum > prime_list[-1]:
+ break
+
+ if sum in prime_set and count > max_count:
+ max_sum = sum
+ max_count = count
+
+print max_sum
+