-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp007.py
More file actions
31 lines (24 loc) · 660 Bytes
/
p007.py
File metadata and controls
31 lines (24 loc) · 660 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
#
import os,logging
import time
import math
from prime import PrimeNumberPool
def main(args):
description = '''
10001st prime
Problem 7
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
What is the 10 001st prime number?
'''
primes = PrimeNumberPool()
if args.test:
logging.info('Running test...')
idx = 6-1
else:
idx = 10001-1
num_primes = primes.NumberOfPrimes()
for i in range(idx+1-num_primes):
primes.NewPrime()
result = primes.numbers[idx]
solution = 'result: {}'.format(result)
logging.info(solution)