Finding first n primes? [duplicate]
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Fastest way to list all primes below N in python Although I already have written a function to find all primes under n ( primes(10) -> [2, 3, 5, 7] ), I am struggling to find a quick way to find the first n primes. What is the fastest way to do this? 回答1: Start with the estimate g(n) = n log n + n log log n *, which estimates the size of the nth prime for n > 5. Then run a sieve on that estimate. g(n) gives an