1

It looks like the gap between $n$ and the $n$-th prime is increasing as $n$ gets bigger.

Is there any function describing this increase?

If I would like to find the $n$-th prime with the sieve of Eratosthenes, what is the smallest array I can use?

Ѕᴀᴀᴅ
  • 34,263
KOB
  • 121
  • 1
    Maybe you can start by considering the $n$th prime ... https://math.stackexchange.com/questions/1257/is-there-a-known-mathematical-equation-to-find-the-nth-prime – Matti P. Apr 05 '18 at 10:16
  • And if you're just using a list of primes as the sieve, it's fairly easy to see that, if the largest prime on the sieve list is $p$, you will start having problems if you're checking numbers after $p^2$. Therefore, there is no 'smallest array', unless you consider only a finite list of primes. – Matti P. Apr 05 '18 at 10:19
  • No, there isn't really anything precise like this. Maybe you might find this of interest? https://en.wikipedia.org/wiki/Prime_number_theorem – supersmarty1234 Apr 05 '18 at 10:22
  • Why is there a downvote? I think its a simple question with no known answer to me, not even in the links provided in the comments have the answer. People just downvote when they dont know the answer? – KOB Apr 05 '18 at 15:35
  • Are you optimizing your array in any sort of way? For instance, if you exclude even numbers, you might need an array of only half the size. Are you working in Java or C++ or Wolfram or something like that? – Mr. Brooks Apr 05 '18 at 23:19
  • @Mr.Brooks the even numbers are good idea. – KOB Apr 06 '18 at 17:49

2 Answers2

1

It looks like the best answer to the last question is:

n(ln(n)) + n(ln(ln(n)))

But I did not find any proof this is the smallest number for an upper bound can be calculated.

I sort of answered my own question because no one willing to. In comments the wikipedia link to prime theory doesn't help, it's the same telling me: "Find the answers in mathematics". p^2 is obviously too big, there is much smaller solution. I got down voted god knows why. You just scaring away curious people from science.

KOB
  • 121
1

By the prime number theorem, there are about $N/$$\log(N)$ primes less then or equal to $N$. So the $N$th prime is roughly $N$$\log N$. As you might notice, the $N$th prime is not exponentially smaller or larger than $N$. It is almost the same size as $N$, slightly larger. Of course, there are better approximations.

J. Linne
  • 3,022