You are viewing a single comment's thread. Return to all comments →
import math def sieve_of_eratosthenes(limit): is_prime = [True] * (limit + 1) p = 2 while p * p <= limit: if is_prime[p]: for i in range(p * p, limit + 1, p): is_prime[i] = False p += 1 prime_numbers = [p for p in range(2, limit + 1) if is_prime[p]] return prime_numbers t = int(input()) for j in range(t): n = int(input()) if n < 6: limit = 15 else: limit = int(n * (math.log(n) + math.log(math.log(n)))) # returns a int(float) primes = sieve_of_eratosthenes(limit) 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 →