E. D. F. Meissel, a German astronomer, found in the 1870’s a method for computing individual values of π(x), the counting function for the number of primes ≤ x. His method was based on recurrences for partial sieving functions, and he used it to compute π( 109 ). D. H. Lehmer simplified and extended Meissel’s method. We present further refinements of the Meissel-Lehmer method which incorporate some new sieving techniques. We give an asymptotic running time analysis of the resulting algorithm, showing that for every ε > 0 it computes π(x) using at most O(x 2/3 + ε ) arithmetic operations and using at most O(x 1/3 + ε ) storage locations on a Random Access Machine (RAM) using words of length [ log 2 x] + 1 bits. The algorithm can be further speeded up using parallel processors. We show that there is an algorithm which, when given M RAM parallel processors, computes π(x) in time at most O(M − 1 x 2/3 + ε ) using at most O(x 1/3 + ε ) storage locations on each parallel processor, provided M ≤ x 1/3 . A variant of the algorithm was implemented and used to compute π( 4×1016 ). COMPUTING π(x): THE MEISSEL-LEHMER METHOD J. C. Lagarias AT&T Bell Laboratories Murray Hill, New Jersey V. S. Miller IBM Watson Research Center Yorktown Heights, New York A. M. Odlyzko AT&T Bell Laboratories Murray Hill, New Jersey
[1]
Jeffrey C. Lagarias,et al.
New algorithms for computing π(x)
,
1984
.
[2]
Jan Bohman.
On the number of primes less than a given limit
,
1972
.
[3]
Meissel.
Berechnung der Menge von Primzahlen, welche innerhalb der ersten Milliarde natürlicher Zahlen vorkommen
,
1885
.
[4]
Alfred V. Aho,et al.
The Design and Analysis of Computer Algorithms
,
1974
.
[5]
D. H. Lehmer.
On the exact number of primes less than a given limit
,
1959
.
[6]
L. Dickson.
History of the Theory of Numbers
,
1924,
Nature.
[7]
Meissel.
Berechnung der Menge von Primzahlen. welche innerhalb der ersten Hundert Millionen natürlicher Zahlen vorkommen
,
1871
.
[8]
Meissel.
Ueber die Bestimmung der Primzahlenmenge innerhalb gegebener Grenzen
,
1870
.
[9]
Martin Hopkins,et al.
An overview of the PL.8 compiler
,
1982,
SIGP.
[10]
Herbert S. Wilf.
What is an Answer
,
1982
.
[11]
David C. Mapes.
Fast method for computing the number of primes less than a given limit
,
1963
.