The prime counting function $ \pi (x) \approx \dfrac {x} {\ln(x-1)} $. This function returns the number of primes less than $x$.
Note: $x-1$ gives a better estimate than $x$.
How to find $x$ given $ \pi(x) $ ?
The prime counting function $ \pi (x) \approx \dfrac {x} {\ln(x-1)} $. This function returns the number of primes less than $x$.
Note: $x-1$ gives a better estimate than $x$.
How to find $x$ given $ \pi(x) $ ?
There is of course not just one solution, since multiple integers n will have the same value $\pi(n)$. You could create a unique solution by asking for the n-th prime.
A good approximation for $\pi(n)$ is $\pi(n) = li(n) + O (1/n)$. $pi(n)$ behaves as if it was the sum of the logarithmic integral $li(n)$ which isn't hard to calculate, plus a pseudo-random component. For x that isn't too large, you use usual numerical methods to find an n with $li(n) \approx x$. The value $\pi(n)$ will be O(n) away from this.
So you use a method that calculates $pi(n)$ exactly, which can be done in $O(n^{2/3})$ steps, and which is close to but not equal to x. Then you determine an interval that ought to contain the n with $\pi(n) = x$ and use a sieve to calculate $\pi(n)$ for all n in this interval.
If what you are looking for is bounds, you could use something like this.
Consider the following non-asymptotic bounds for $\pi(x)$, proven by Dusart in 2018 (holding for $x>5393$):
$$\frac{x}{\log(x)-1}<\pi(x)<\frac{x}{\log(x)-1.112}$$
To get the maximum value for $p(n)$, we take the lower bound with $x=p(n)$ :
$$\pi(p(n))=\frac{p(n)}{\log p(n)-1}$$ $$n\left(\log p(n)-1\right)-p(n)=0$$ $$p(n)=-nW_{-1}\left(\frac{-e^{1}}{n}\right)$$
$W_{k}(n)$ is the analytic continuation of the product log function. Now if we do the same with the upper bound, we get non-asymptotic bounds for the $N^{th}$ prime $p(n)$:
$$-nW_{-1}\left(\frac{-e^{1.112}}{n}\right)<p(n)<-nW_{-1}\left(\frac{-e}{n}\right)$$
Whith these bounds you know how far you would have to check to get $n$ primes, like you said in your comment...