A method for computing the prime counting function. Define the function
| 
 
(1)
 
 | 
where 
 is the floor function and the 
 are the binary digits (0 or 1) in
| 
 
(2)
 
 | 
Legendre's formula can then be written
| 
 
(3)
 
 | 
The first few values of 
 are
| 
 
(4)
 
 | |||
| 
 
(5)
 
 | |||
| 
 
(6)
 
 | |||
| 
 
(7)
 
 | |||
| 
 
(8)
 
 | |||
| 
 
(9)
 
 | |||
| 
 
(10)
 
 | |||
| 
 
(11)
 
 | 
Mapes' method takes time ,
 which is slightly faster than the Lehmer-Schur
 method.