-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem10.py
More file actions
38 lines (32 loc) · 725 Bytes
/
problem10.py
File metadata and controls
38 lines (32 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Problem 10
#
#Find the greatest product of five consecutive digits in the 1000-digit number.
#The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
#
# @date 12/03/2012
# @author Ciarán McCann
# @website http://ciaranmccann.me/
def genPrimeList(upTo):
primeNth = 0
numbers = []
for i in range(0,upTo):
numbers.append(i)
numbers[1] = 0
p = 2
n = 2
#printGridArray(numbers)
while True:
n = 2
while n*p < len(numbers): # remove all multplies
numbers[n*p] = 0
n += 1
while p < len(numbers): # find next multiple to remove
p += 1
if p == len(numbers):
return numbers
if numbers[p] != 0:
p = numbers[p]
primeNth += 1
break
primes = genPrimeList(2000000)
print(sum(primes))