-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp010.py
More file actions
34 lines (26 loc) · 714 Bytes
/
p010.py
File metadata and controls
34 lines (26 loc) · 714 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
#
import os,logging
import time
import math
from prime import PrimeNumberPool
def main(args):
description = '''
Summation of primes
Problem 10
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
'''
if args.test:
maxp = 10
else:
maxp = 2*1000*1000
ts1 = time.time()
primes = PrimeNumberPool(maxp)
ts2 = time.time()
logging.debug('time for build prime number pool: {}'.format(ts2-ts1))
if primes.GetLargestPrime() > maxp:
result = sum(primes.numbers[:-1])
else:
result = sum(primes.numbers)
solution = 'result: {}'.format(result)
logging.info(solution)