Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I'm helping my son with Project Euler and we're working on problem 7, "What is the 10001st prime number?" We'll use a Sieve of Eratosthenes and we'll increase the size of the initial array until we're left with 10001 primes. We'll start with a pretty big array and increase it by whatever seems reasonable, since there is no time constraint, until we get the answer.

My question is, is there a way to make an informed guess about the size of the initial array?

share|improve this question

1 Answer 1

up vote 9 down vote accepted

Wikipedia gives the bounds $n \ln n + n(\ln\ln n - 1) < p_n < n \ln n + n \ln \ln n$, where $p_n$ is the $n$th prime. So the $10001$st prime is between 104318 and 114320.

share|improve this answer
1  
Wow, I can't believe I haven't run into that before. –  uncle brad Jun 19 '11 at 13:07
5  
@Luboš, when the question says that the OP is trying to solve a problem and just wants to allocate the right amount of memory to start with, it probably means he doesn't want to be told the solution. –  Peter Taylor Jun 19 '11 at 14:15
2  
@Luboš Please delete your comment, it is a spoiler for those who still want to solve the problem. –  starblue Jun 19 '11 at 16:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.