You are viewing a single comment's thread. Return to all comments →
I generated the first 10k primes with the sieve of erastosthenes and that was it! Just access the nth value from the array!
x = 110000 primes = [True]*x p = 2 while p <= x**.5: if primes[p]: for i in range(p+p, x, p): primes[i] = False p += 1 primeNos = [] for i in range(2, len(primes)): if primes[i]: primeNos.append(i) for _ in range(int(input())): n = int(input()) print(primeNos[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 →
I generated the first 10k primes with the sieve of erastosthenes and that was it! Just access the nth value from the array!