[−][src]Function primecount::pi
pub fn pi(x: i64) -> i64
Counts the number of primes <= x
using Xavier Gourdon's
algorithm. Uses all CPU cores by default.
Returns -1 if an error occurs.
Examples
// The primes are: 2, 3, 5 and 7. assert_eq!(primecount::pi(10), 4); // The primes are: 2, 3, 5, 7 and 11. assert_eq!(primecount::pi(11), 5); assert_eq!(primecount::pi(10i64.pow(12)), 37607912018);
- Run time complexity: O(x^(2/3) / (log x)^2)
- Memory usage: O(x^(1/3) * (log x)^3)