[][src]Function reikna::prime_count::prime_count

pub fn prime_count(x: u64) -> u64

Return the number of prime numbers less than or equal to x.

This function works by using a lookup table if x is very small (less than 100), and otherwise using a recursive version of Lehmer's Formula.

Note that this function can take a very long time to produce a result if x is very large.

If multiple values of the prime-counting function are being calculated, prime_count_all() is a better choice because it preserves its caches between calculations. See the documentation for prime_count_all for more information.

Panics

Panics if prime_sieve() panics, see the documentation of prime_sieve() for more information.

Examples

use reikna::prime_count::prime_count;
assert_eq!(prime_count(1_000), 168);
assert_eq!(prime_count(10_000), 1_229);