Function prime_suspects::eratosthenes_sieve
[−]
[src]
pub fn eratosthenes_sieve(max_val: usize) -> Vec<usize>
An implementation of the sieve of Eratosthenes, as described in the Wikipedia article.
Examples
Compute the primes in the first ten integers.
assert_eq!(vec![2,3,5,7], prime_suspects::eratosthenes_sieve(10));
Compute the last three primes up to 264.
assert_eq!(vec![65521, 65519, 65497], prime_suspects::eratosthenes_sieve(65535) .into_iter().rev().take(3) .collect::<Vec<usize>>());