The pseudosquares prime sieve

  • Authors:
  • Jonathan P. Sorenson

  • Affiliations:
  • Computer Science and Software Engineering, Butler University, Indianapolis, IN

  • Venue:
  • ANTS'06 Proceedings of the 7th international conference on Algorithmic Number Theory
  • Year:
  • 2006

Quantified Score

Hi-index 0.00

Visualization

Abstract

We present the pseudosquares prime sieve, which finds all primes up to n. Define p to be the smallest prime such that the pseudosquare Lp n/(π(p)(logn)2); here π(x) is the prime counting function. Our algorithm requires only O(π(p)n) arithmetic operations and O(π(p)logn) space. It uses the pseudosquares primality test of Lukes, Patterson, and Williams. Under the assumption of the Extended Riemann Hypothesis, we have p≤2(logn)2, but it is conjectured that $p\sim \frac{1}{\log 2}\log n \log\log n$. Thus, the conjectured complexity of our prime sieve is O(nlogn) arithmetic operations in O((logn)2) space. The primes generated by our algorithm are proven prime unconditionally. The best current unconditional bound known is $p \le n^{1/(4\sqrt{e}-\epsilon)}$, implying a running time of roughly n1.132 using roughly n0.132 space. Existing prime sieves are generally faster but take much more space, greatly limiting their range (O(n/loglogn) operations with n1/3+ε space, or O(n) operations with n1/4 conjectured space). Our algorithm found all 13284 primes in the interval [1033,1033+106] in about 4 minutes on a 1.3GHz Pentium IV. We also present an algorithm to find all pseudosquares Lp up to n in sublinear time using very little space. Our innovation here is a new, space-efficient implementation of the wheel datastructure.