## The Pseudosquares Prime Sieve

Citations: | 1 - 1 self |

### BibTeX

@MISC{Sorenson_thepseudosquares,

author = {Jonathan P. Sorenson},

title = {The Pseudosquares Prime Sieve},

year = {}

}

### OpenURL

### Abstract

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)(log n) 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(log n) 2, but it is conjectured that p ∼ 1 log nlog log n. Thus, log2 the conjectured complexity of our prime sieve is O(n log n) arithmetic operations in O((log n) 2) space. The primes generated by our algorithm are proven prime unconditionally. The best current unconditional bound known is p ≤ n 1/(4√e−ɛ) 1.132, implying a running time of roughly n using roughly n 0.132 space. Existing prime sieves are generally faster but take much more space, greatly limiting their range (O(n / log log n)operationswithn 1/3+ɛ space, or O(n) operationswithn 1/4 conjectured space). Our algorithm found all 13284 primes in the interval [10 33,10 33 +10 6] in about 4 minutes on a1.3GHzPentiumIV. 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. 1

### Citations

1496 | The C++ Programming Language
- Stroustrup
- 1997
(Show Context)
Citation Context ...ddressed either at the bit level or at the word level, where each machine word is composed of O(log n) bits. When we present code fragments, we use a C++ style that should be familiar to most readers =-=[25]-=-. We occasionally declare integer variables with an INT datatype instead of the int datatype. This indicates that these integers typically exceed 32 bits in practice and may require special implementa... |

854 |
An Introduction to the Theory of Numbers
- Hardy, Wright
- 1979
(Show Context)
Citation Context ...1 + o(1)); (2) p≤x � 1=π(x)= p≤x x (1 + o(1)); log x � � � p − 1 1 = O ; p log x p≤x (3) (4) � 1 φ(m) = d m log(x2/x1)(1 + o(1)). (5) x 1 <d≤x 2 gcd(d,m)=1 For proofs of (1)–(4), see Hardy and Wright =-=[14]-=-. For a proof of (5), see [23, Lemma 1]. 2.5 The Wheel A wheel, as we will use it, is a data structure that encapsulates information about the integers relatively prime to the first k primes. Generall... |

206 |
Riemann's Hypothesis and Tests for Primality
- Miller
- 1976
(Show Context)
Citation Context ... factor with the 2-psp test, and another log n factor because in this paper we count arithmetic operations instead of bit operations.) WecanimprovethetimetoO(n(log n) 2 ) by using Miller’s prime test =-=[16]-=-, but then our output is correct only if the ERH is true. And of course if we are willing to accept probable primes, the Miller-Rabin [20] or Solovay-Strassen [22] tests could give us O(n log n) opera... |

189 |
Probabilistic Algorithm for Testing Primality
- Rabin
- 1980
(Show Context)
Citation Context ...animprovethetimetoO(n(log n) 2 ) by using Miller’s prime test [16], but then our output is correct only if the ERH is true. And of course if we are willing to accept probable primes, the Miller-Rabin =-=[20]-=- or Solovay-Strassen [22] tests could give us O(n log n) operations.Butinmostapplicationsforprimesieves, we need to be certain of our output. In this paper, we present a new prime number sieve, the ps... |

80 |
The Gnu Multiple Precision Arithmetics Library 2.0.2
- Granlund
- 1996
(Show Context)
Citation Context ...instead of the int datatype. This indicates that these integers typically exceed 32 bits in practice and may require special implementation (we used the Gnu-MP mpz t datatype and associated functions =-=[13]-=-). We still limit INTs to O(log n) bits. The space used by an algorithm under our model is counted in bits. The space used by the output of a prime number sieve (the list of primes up to n) isnot coun... |

41 | Detecting perfect powers in essentially linear time
- Bernstein
- 1998
(Show Context)
Citation Context ... are either prime or the power of a prime. Note that if n ≤ 6.4·10 37 , only primes remain and we are done [26, p. 417]. To remove the prime powers, in theory we use a perfect power testing algorithm =-=[6,7,9]-=- which, in our model of computation, requires sublinear time per integer on average, making the cost negligible (o(Δ) operations on average, since we only perform the tests on the remaining O(Δ/ log n... |

32 |
A fast Monte Carlo test for primality
- Solovay, Strassen
- 1977
(Show Context)
Citation Context ... n) 2 ) by using Miller’s prime test [16], but then our output is correct only if the ERH is true. And of course if we are willing to accept probable primes, the Miller-Rabin [20] or Solovay-Strassen =-=[22]-=- tests could give us O(n log n) operations.Butinmostapplicationsforprimesieves, we need to be certain of our output. In this paper, we present a new prime number sieve, the pseudosquares prime sieve (... |

26 |
Analytic Methods in the Analysis and Design of Number-Theoretic Algorithms
- Bach
- 1984
(Show Context)
Citation Context ... then Algorithm PSSPS finds all primes up to n in O(n(log n) 2 / loglog n) arithmetic operations and O((log n) 3 / log log n) space.sThe Pseudosquares Prime Sieve 201 This follows from Bach’s Theorem =-=[3]-=-, which implies p<2(log n) 2 , or asymptotically p<(1 + o(1))(log n) 2 . Note that this weaker result still outperforms the use of Miller’s prime test [16] or AKS [1,8] in a prime sieve. Currently the... |

17 |
A sublinear additive sieve for finding prime numbers
- Pritchard
- 1981
(Show Context)
Citation Context ...ation of the wheel datastructure. 1 Introduction A prime number sieve is an algorithm that finds all prime numbers up to a bound n. The fastest known sieves take O(n/ log log n) arithmetic operations =-=[2,10,18,23]-=-, which is quite fast, considering there are π(n) ∼ n/ logn primes to find. However in practice, the utility of a prime number sieve is often limited by how much memory space it needs. For example, a ... |

16 | Some results on pseudosquares
- Lukes, Patterson, et al.
- 1996
(Show Context)
Citation Context ...ve (Algorithm PSSPS), that uses very little space and yet is fast enough to be practical. It uses an Eratosthenes-like sieve followed by the pseudosquares prime test of Lukes, Patterson, and Williams =-=[15]-=- (which effectively includes a base-2 pseudoprime test). Our sieve has a conjectured running time of O(n log n) arithmetic operations and O((log n) 2 ) bits of space. This is the complexity we observe... |

15 |
The pseudoprimes to 25
- Pomerance, Selfridge, et al.
- 1980
(Show Context)
Citation Context ...eparately, we would only need O(log n) space, but the time of O(n √ n/ logn) would be prohibitive. We could sieve by a few primes, then apply a quick base-2 pseudoprime test to remove most composites =-=[17]-=- and then use a prime test. If we used the AKS test [1] with Bernstein’s complexity improvements [8], the result would be a sieve that takes n(log n) 2+o(1) operations. (The modified AKS test is (log ... |

11 | Detecting perfect powers by factoring into coprimes
- Bernstein, Lenstra, et al.
(Show Context)
Citation Context ... are either prime or the power of a prime. Note that if n ≤ 6.4·10 37 , only primes remain and we are done [26, p. 417]. To remove the prime powers, in theory we use a perfect power testing algorithm =-=[6,7,9]-=- which, in our model of computation, requires sublinear time per integer on average, making the cost negligible (o(Δ) operations on average, since we only perform the tests on the remaining O(Δ/ log n... |

10 |
Statistical evidence for small generating sets
- Bach, Huelsbergen
- 1993
(Show Context)
Citation Context ...the following. Theorem 3.1. Let p be defined as above. Algorithm PSSPS finds all primes up to n using O(π(p)n)+o(n log n) arithmetic operations and O(π(p)logn) space. The work of Bach and Huelsbergen =-=[4]-=- implies the following conjecture. Conjecture 3.2. log Lp ∼ log 2 p 1 log p ,orequivalently,p∼log 2 log Lp log log Lp. Lukes, Patterson, and Williams [15] studied the relationship between Lp and p for... |

9 | Prime sieves using binary quadratic forms
- Atkin, Bernstein
- 2004
(Show Context)
Citation Context ...ation of the wheel datastructure. 1 Introduction A prime number sieve is an algorithm that finds all prime numbers up to a bound n. The fastest known sieves take O(n/ log log n) arithmetic operations =-=[2,10,18,23]-=-, which is quite fast, considering there are π(n) ∼ n/ logn primes to find. However in practice, the utility of a prime number sieve is often limited by how much memory space it needs. For example, a ... |

9 |
Sieve algorithms for perfect power testing
- Bach, Sorenson
- 1993
(Show Context)
Citation Context ... are either prime or the power of a prime. Note that if n ≤ 6.4·10 37 , only primes remain and we are done [26, p. 417]. To remove the prime powers, in theory we use a perfect power testing algorithm =-=[6,7,9]-=- which, in our model of computation, requires sublinear time per integer on average, making the cost negligible (o(Δ) operations on average, since we only perform the tests on the remaining O(Δ/ log n... |

9 |
Fast compact prime number sieves (among others
- Pritchard
- 1983
(Show Context)
Citation Context ...ering there are π(n) ∼ n/ logn primes to find. However in practice, the utility of a prime number sieve is often limited by how much memory space it needs. For example, a sieve that uses O( √ n)space =-=[2,19,23]-=- cannot, on current hardware, generate primes larger than about 10 18 . ⋆ This work was supported by a grant from the Holcomb Research Institute. Special thanks to Hugh Williams for helpful discussion... |

8 |
Two Fast Parallel Prime Number Sieves
- Sorenson, Parberry
- 1994
(Show Context)
Citation Context ...our C++ notation, we will declare W to be of class type Wheel(k),wherek is an integer parameter. We can construct a wheel of size Mk in O(Mk) operations. For examples of the wheel data structure, see =-=[19,24]-=-. 3 Algorithm PSSPS 3.1 Precomputations and Main Loop We first construct a table of pseudosquares up to n/(log n) 2 using the algorithm we describe later in §4. In the code fragment below, this is sto... |

8 | Édouard Lucas and Primality Testing, Canadian - Williams - 1998 |

3 | A space-efficient fast prime number sieve
- Dunten, Jones, et al.
(Show Context)
Citation Context ...ation of the wheel datastructure. 1 Introduction A prime number sieve is an algorithm that finds all prime numbers up to a bound n. The fastest known sieves take O(n/ log log n) arithmetic operations =-=[2,10,18,23]-=-, which is quite fast, considering there are π(n) ∼ n/ logn primes to find. However in practice, the utility of a prime number sieve is often limited by how much memory space it needs. For example, a ... |

3 |
Dissecting a sieve to cut its need for space
- Galway
- 2000
(Show Context)
Citation Context ...mproved this paper. F. Hess, S. Pauli, and M. Pohst (Eds.): ANTS 2006, LNCS 4076, pp. 193–207, 2006. c○ Springer-Verlag Berlin Heidelberg 2006s194 J.P. Sorenson Even with Galway’s clever improvements =-=[11]-=- to the Atkin-Bernstein sieve [2], the space requirement is still n 1/3+ɛ , giving an effective limit of roughly 10 27 . Galway also has a sieve with conjectured space use of O(n 1/4 ) that runs linea... |

3 |
Analytic computation of the prime-counting function
- Galway
- 2000
(Show Context)
Citation Context ...ture may prove to be useful in other areas of computational number theory. For more on finding pseudosquares, see Wooding and Williams [28] in this volume. For recent work on prime number sieves, see =-=[2,11,12,23]-=-. The rest of this paper is organized as follows. In §2 we discuss some preliminaries, including pseudosquares, followed by a description of our algorithm in §3. In §4 we present our new wheel data st... |

2 |
Proving primality in essentially quartic time
- Bernstein
- 2006
(Show Context)
Citation Context ... could sieve by a few primes, then apply a quick base-2 pseudoprime test to remove most composites [17] and then use a prime test. If we used the AKS test [1] with Bernstein’s complexity improvements =-=[8]-=-, the result would be a sieve that takes n(log n) 2+o(1) operations. (The modified AKS test is (log n) 4+o(1) bit operations; we save a log n factor with the 2-psp test, and another log n factor becau... |

1 |
On pseudosquares. New Trends in Prob
- Schinzel
- 1997
(Show Context)
Citation Context ...t this weaker result still outperforms the use of Miller’s prime test [16] or AKS [1,8] in a prime sieve. Currently the best unconditional result is p ≤ Lp 1/(4√ e−ɛ) ≈ Lp 0.1516... , due to Schinzel =-=[21]-=-. Since we use Lp ≈ n/p, we obtain that p ≈ n 1/(4√ e+1−ɛ) ≈ n 0.132 . This implies the following much weaker result: Corollary 3.5. Let ɛ>0. Algorithm PSSPS finds all primes up to n in O(n 1+1/(4√ e+... |

1 | Trading time for space in prime number sieves
- Sorenson
- 1998
(Show Context)
Citation Context |

1 | Development of a high-speed hybrid sieve architecture - Wooding - 2003 |

1 | Doubly-focused enumeration of pseudosquares and pseudocubes
- Wooding, Williams
- 2006
(Show Context)
Citation Context ...(n · exp[−c log n/ loglog n]) for a constant c>0. This data structure may prove to be useful in other areas of computational number theory. For more on finding pseudosquares, see Wooding and Williams =-=[28]-=- in this volume. For recent work on prime number sieves, see [2,11,12,23]. The rest of this paper is organized as follows. In §2 we discuss some preliminaries, including pseudosquares, followed by a d... |