Meissel–Lehmer algorithm

[1][2] The problem of counting the exact number of primes less than or equal to x, without actually listing them all, dates from Legendre.

He observed from the Sieve of Eratosthenes that where ⌊x⌋ is the floor function, which denotes the greatest integer less than or equal to x and the pi run over all primes ≤ √x.

[1][2] Since the evaluation of this sum formula becomes more and more complex and confusing for large x, Meissel tried to simplify the counting of the numbers in the Sieve of Eratosthenes.

[1] With the starting condition and the recurrence each value for φ(x,a) can be calculated recursively.

[1] Jeffrey Lagarias, Victor Miller and Andrew Odlyzko published a realisation of the algorithm which computes π(x) in time O(x2/3+ε) and space O(x1/3+ε) for any ε > 0.