[][src]Function reikna::prime::prime_sieve

pub fn prime_sieve(max: u64) -> Vec<u64>

Idiomatic prime sieve, returns a Vec<u64> of primes in [1, max].

If you want to generate primes, this is probably the function you want.

This function will use atkin() to generate primes if max is less than S_SIEVE_SIZE, otherwise it will use segmented_eratosthenes().

See atkin() and segmented_eratosthenes() for more information.

Panics

Panics if max is too large to cast into a usize.

Examples

use reikna::prime::prime_sieve;
assert_eq!(prime_sieve(20), vec![2, 3, 5, 7, 11, 13, 17, 19]);