24 lines
549 B
Python
24 lines
549 B
Python
# coding=utf-8
|
|
''' 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? '''
|
|
|
|
import math
|
|
|
|
def countp(count):
|
|
if count == 1: return 2
|
|
prime = [2]
|
|
x = 1
|
|
while 1:
|
|
for i in xrange(x ** 2 + (x + 1) % 2, (x + 1) ** 2, 2):
|
|
for p in prime:
|
|
if i % p == 0: break
|
|
else: count -= 1
|
|
if count == 0: return i
|
|
x += 1
|
|
for p in prime:
|
|
if x % p == 0: break
|
|
else: prime.append(x)
|
|
|
|
if __name__ == '__main__':
|
|
print countp(10001)
|