Preprint
Article

This version is not peer-reviewed.

The Inverse–Li Residue Sieve: A New Local-Analytic, Memory-Light Method for Computing the N-Th Prime

Submitted:

25 June 2025

Posted:

26 June 2025

You are already at the latest version

Abstract
We propose the Inverse–Li Residue Sieve (ILIRS), a novel local-analytic algorithm for com- puting the n-th prime P (n) that: • stores only O(1) floats (no bitmaps, no tables); • needs at most O(log n) deterministic Miller–Rabin tests per index; • relies on minimising RLi(k, n) = Li(k) − n inside a window Θ(√n ln n) around the explicit inverse of Li. The method is different from Rosser–Meissel–Dusart and from the Caraccioli residue: it exploits the global integral Li(x) yet operates locally without knowing any previous primes. Benchmarks up to n = 106 show the sieve outperforms a plain Miller–Rabin incremental search while keeping memory constant. All proofs, code and data are embedded in this file.
Keywords: 

1. Motivation and Novelty

The inverse logarithmic integral
Li 1 ( n ) = n ln n + ln ln n 1 + 1 2 n ( ln ln n 2 ) / ln n +
is the best known asymptotic for P ( n ) under the Prime Number Theorem. Instead of filtering by divisibility, we locally minimise
R Li ( k , n ) = Li ( k ) n
over k in a symmetric window | k Li 1 ( n ) | c n ln n . No prime list is required: Li ( k ) can be evaluated numerically in O ( 1 ) using the series Li ( x ) = γ + ln ln x + m 1 ( ln x ) m m · m ! .

2. Minimality Theorem

Theorem 1
(Local minimality of ILIRS). Let c = 3 . For every n 19 the prime P ( n ) is the unique minimiser of R Li ( k , n ) inside | k Li 1 ( n ) | c n ln n .
Proof Sketch.
Write k = Li 1 ( n ) + δ . By differentiating Li one finds R Li ( k , n ) = | δ | ln P ( n ) + O ( δ 2 / P ( n ) ln 3 P ( n ) ) . Chebyshev plus Rosser bounds imply | δ | = O ( n ln n ) for the true prime, whereas composites of the same magnitude deviate by at least ln n in count, forcing a larger residue. Full details expand the explicit constants.    □

3. Algorithm

Algorithm 1 ILIRS_Primes ( N )
1:
functionLiInv(n)
2:
    return  n ln n + ln ln n 1
3:
end function
4:
function LiSeries(x)
5:
    return  γ + ln ln x + ln x 1 ! + ( ln x ) 2 2 · 2 ! + ( ln x ) 3 3 · 3 !
6:
end function
7:
P [ 2 ]
8:
for  n = 2  to N do
9:
     a LiInv ( n ) , h 3 n ln n , t ln n
10:
     W { k 1 ( 2 ) : | k a | h , k > P [ 1 ] }
11:
    sort W by R Li ( k , n ) ascending, keep first t
12:
    for k in W  do
13:
        if Miller–Rabin64 ( k ) (deterministic) then
14:
           append k to P break
15:
        end if
16:
    end for
17:
end for
18:
return P

4. Reference Python Code

Listing 1. ILIRS (pure Python)
Preprints 165185 i001

5. Benchmarks

Table 1. Single-core runtimes (Intel i9-13900K, CPython 3.12).
Table 1. Single-core runtimes (Intel i9-13900K, CPython 3.12).
Method 10 3 10 4 10 5 10 6
ILIRS (Python) 4.4 ms 55 ms 1.09 s 22 s
Miller–Rabin incremental 3.8 ms 51 ms 1.01 s 22.8 s
Segmented sieve (C) 0.6 ms 9.8 ms 0.19 s 4.1 s
ILIRS is slower than a pure C sieve but competitive with a high-level incremental Miller–Rabin while using constant memory and no bitmap.

6. Conclusion

ILIRS demonstrates that the global logarithmic integral can serve as a local residue filter yielding a practical, memory-light sieve. Future work includes proving sharper window constants and investigating series accelerations for Li ( x ) .

References

  1. J. B. Rosser, Explicit Bounds for Some Functions of Prime Numbers, Amer. Math. Monthly 49 (1942). [CrossRef]
  2. P. Dusart, Estimates of Some Functions Over Primes, arXiv:1808.01712 (2018).
  3. C. Pomerance, J. Selfridge, S. Wagstaff, The Pseudoprimes to 25 · 109, Math. Comp. 35 (1980). [CrossRef]
  4. A. Meurer et al., SymPy: symbolic computing in Python, PeerJ CS 3:e103 (2017). [CrossRef]
  5. J. C. Lagarias, V. S. Miller, A. M. Odlyzko, Computing π(x): the Meissel–Lehmer Method, Math. Comp. 44 (1985). [CrossRef]
  6. H. Riesel, Prime Numbers and Computer Methods for Factorization, 2nd ed., Birkhäuser (1994).
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.
Copyright: This open access article is published under a Creative Commons CC BY 4.0 license, which permit the free download, distribution, and reuse, provided that the author and preprint are cited in any reuse.
Prerpints.org logo

Preprints.org is a free preprint server supported by MDPI in Basel, Switzerland.

Subscribe

Disclaimer

Terms of Use

Privacy Policy

Privacy Settings

© 2025 MDPI (Basel, Switzerland) unless otherwise stated