n_nth_prime, n_nth_prime_bounds
Synopsis
#include <flint/ulong_extras.h>n_nth_prime makes sure the table of cached primes is large enough and looks up the entry. n_nth_prime_bounds does not check for overflow, so its bounds are meaningless for large n. It uses the estimates, valid for n > 5,
\begin{aligned}
p_n &> n (\ln n + \ln \ln n - 1), \\
p_n &< n (\ln n + \ln \ln n), \\
p_n &< n (\ln n + \ln \ln n - 0.9427) \quad (n \ge 15985).
\end{aligned}
The first inequality is due to Dusart [Dus1999] and the last to Massias and Robin [MasRob1996].
References#
- [Dus1999] P. Dusart, "The k^{th} prime is greater than k(\ln k+\ln \ln k-1) for k \ge 2," Math. Comp., 68:225 (January 1999) 411–415.
- [MasRob1996] J. Massias and G. Robin, "Bornes effectives pour certaines fonctions concernant les nombres premiers," J. Theorie Nombres Bordeaux, 8 (1996) 215-242.
Cite this page
The FLINT team, “n_nth_prime, n_nth_prime_bounds (ulong_extras.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/ulong_extras/n_nth_prime.html (generated 2026-10-20).
@misc{flint-doc-ulong-extras-n-nth-prime,
author = {{The FLINT team}},
title = {{n\_nth\_prime, n\_nth\_prime\_bounds (ulong\_extras.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/ulong_extras/n_nth_prime.html},
note = {Generated 2026-10-20}
}