project euler 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?

http://projecteuler.net/problem=7


highlight below for my solution:


#using a prime number set datastructure - https://gist.github.com/aausch/6709819
p =  PrimeSet()

i = 10001

while (len(p)<10001):
    i in p
    i += i

print sorted(list(p))[10000]

(see also my solution to problem #5)


[More programming riddles]

Leave a comment