Optimization of an Explicit, Deterministic Formula for All Prime Numbers
THE PRIME NUMBER SERIES 30
Optimization of an Explicit, Deterministic Formula for All Prime Numbers
In THE PRIME NUMBER SERIES 29, an explicit, deterministic formula was presented which yields exactly the i-th prime number
for every natural number
. The formula operates exclusively with elementary arithmetic operations, integer-valued functions, as well as finite sums and products, and generates the prime numbers strictly ordered along the number line.
However, as the index i increases, the computational effort required for direct evaluation grows rapidly. In the present post, it is shown that the very same formula — without any mathematical modification — can be accelerated by several orders of magnitude through a suitable algorithmic evaluation strategy. The core of the improvement lies in the use of proven explicit bounds for
and in an incremental evaluation of the inner summation structure.
Explicit Prime Number Formula
An explicit formula for the i-th prime number is given by

valid for
,
where
![]()
and
![]()
are assumed to be known.
Explicit Bounds and Their Origin
For practical evaluation, functions
and
are used such that the inequality
![]()
always holds.
Lower Bound (Dusart, 2010)
For sufficiently large i, the following proven estimate applies:
![]()
This motivates the definition
![]()
Source:
Pierre Dusart, *Estimates of Some Functions Over Primes without R.H.*, 2010.
Upper Bound (Axler, 2017/2019)
For sufficiently large i, the following proven explicit estimate holds:
![]()
Hence, we define
![]()
Source:
Christian Axler, *New estimates for the n-th prime number*, 2017 / 2019.
Algorithmic Optimization
The decisive algorithmic improvement is based on the observation that the inner sum of the formula can be evaluated incrementally. The summation over n therefore does not need to be recomputed from scratch for each
, but can be extended successively.
For this purpose, the inner summation structure is explicitly formulated as a separate function. Let
![Rendered by QuickLaTeX.com \[ \pi(n_{\min},n_{\max})=\sum_{n=n_{\min}}^{n_{\max}} t(n) \]](https://dieprimzahlenserie.com/wp-content/ql-cache/quicklatex.com-022c601e4346afed375667d8fb462f43_l3.png)
with
![Rendered by QuickLaTeX.com \[ t(n)=\prod_{k=0}^{k_{\max}} \left\lceil 1-\frac{k+\left\lfloor\frac{n-k}{2k+3}\right\rfloor(2k+3)}{n} \right\rceil \]](https://dieprimzahlenserie.com/wp-content/ql-cache/quicklatex.com-f4cdfb82dd8f4147fbfb9edcd49a54f1_l3.png)
and
![Rendered by QuickLaTeX.com \[ k_{\max}=\left\lfloor\frac{\left|\sqrt{2n+3}-3\right|}{2}\right\rfloor, \]](https://dieprimzahlenserie.com/wp-content/ql-cache/quicklatex.com-95416502394d49b34488750ab4e634ff_l3.png)
where
and
.
In particular, this implies
![Rendered by QuickLaTeX.com \[ \sum_{n=1}^{n_{\max}} \left( \prod_{k=0}^{\left\lfloor\frac{\left|\sqrt{2n+3}-3\right|}{2}\right\rfloor} \left\lceil 1-\frac{k+\left\lfloor\frac{n-k}{2k+3}\right\rfloor(2k+3)}{n} \right\rceil \right) =\pi(1,n_{\max}) \]](https://dieprimzahlenserie.com/wp-content/ql-cache/quicklatex.com-ec5baffe044a94a09680f510ecaf481f_l3.png)
where the function
can be incrementally updated according to
![]()
With this notation, the explicit prime number formula can equivalently be written in compact form as
![Rendered by QuickLaTeX.com \[ p_{i} =2m(i)-1 +2\sum_{n_{max}=m(i)-2}^{u(i)} \left\lfloor \left( \frac{i}{\pi(1,n_{max})+3} \right)^{\frac{1}{i}} \right\rfloor. \]](https://dieprimzahlenserie.com/wp-content/ql-cache/quicklatex.com-c5f5627e5595d2f2e38488f0fc33463f_l3.png)
Furthermore, it turns out that the formal upper bound
is usually not fully exhausted in practical evaluation. Once the integer summand attains the value zero for the first time, all subsequent summands contribute nothing further to the result. The effective upper limit thus emerges dynamically during computation.
Examples (Exact Results)
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
Empirical Observation:
While a naive direct evaluation becomes extremely time-consuming for large indices, the optimized evaluation using explicit bounds reduces computation time by several orders of magnitude (e.g., from approximately 37.5 hours to under two minutes for
). By terminating the outer summation at the moment when the integer summand first attains the value zero, the computation time required to determine the 10,000th prime number
) was reduced to approximately 31 seconds.
Acknowledgments
The author thanks Eratosthenes, Euclid, Carl Friedrich Gauss, Georg Cantor, and Hugh Willans for their fundamental contributions to the theory and structure of prime numbers.
Note on the Origin
During the technical review and algorithmic refinement of the evaluation strategy, ChatGPT was used as a supporting tool. The mathematical core idea, the structure of the formula, and the conceptual objective originate from the author.
Munich, December 23, 2025
Gottfried Färberböck

