A Way For Learning

Project Euler #7: 10001st prime

No comments
By listing the first six prime numbers: and , we can see that the prime is .
What is the prime number?

a = [0]*200008
for i in range(2,200000):
    if (a[i] == 1):
        continue
    for j in range(2*i,200000,i):
        a[j] = 1
primes = []
for i in range(2,200000):
    if a[i] == 0:
        primes.append(i)
p = int(input())
for _ in range(p):
 t = int(input())
 print(primes[t-1])

No comments :

Post a Comment