We analyze algorithms for computing the $n$th prime $p_n$ and establish asymptotic bounds for several approaches. Using existing results on the complexity of evaluating the prime-counting function $\pi(x)$, we show that the binary search approach computes $p_n$ in $O(\sqrt{n} \, (\log n)^4)$ time. Assuming the Riemann Hypothesis and Cram\'er's conjecture, we construct a tighter interval around li$^{-1}(n)$, leading to an improved sieve-based algorithm running in $O(\sqrt{n} \, (\log ^{7/2} n) \, \log \log n)$ time. This improvement, though conditional, suggests that further refinements to prime gap estimates may yield provably faster methods for computing primes.
翻译:我们分析了计算第 $n$ 个素数 $p_n$ 的算法,并为几种方法建立了渐近界。利用现有关于计算素数计数函数 $\pi(x)$ 复杂度的结果,我们证明了二分搜索方法可在 $O(\sqrt{n} \, (\log n)^4)$ 时间内计算出 $p_n$。在假设黎曼猜想和克拉默猜想成立的条件下,我们在 li$^{-1}(n)$ 周围构造了一个更紧的区间,从而得到了一种改进的基于筛法的算法,其运行时间为 $O(\sqrt{n} \, (\log ^{7/2} n) \, \log \log n)$。这一改进虽然是条件性的,但表明对素数间隙估计的进一步细化可能产生可证明更快的计算素数方法。