You are viewing a single comment's thread. Return to all comments →
Python 3:
def isPrime(lim): prime = [True] * (lim + 1) prime[0] = prime[1] = False for i in range(2, lim//2 + 1): if prime[i]: for j in range(i*i, lim+1,i): prime[j] = False primeNumber=[] for i in range(2,lim+1): if prime[i]: primeNumber.append(i) return primeNumber LIM=10**6 primes = isPrime(LIM) t = int(input().strip()) for a0 in range(t): n = int(input().strip()) print(primes[n-1])
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #7: 10001st prime
You are viewing a single comment's thread. Return to all comments →
Python 3: