[−][src]Function reikna::prime::atkin
pub fn atkin(max_u64: u64) -> Vec<u64>
Return a Vec<u64>
of the primes in [1, max_u64
] using the
Sieve of Atkin.
This function is best suited for sieving with relatively
small maximums, in which case it is very fast. Large maximums
will start to incur negative performance impacts from
memory allocation, which increases linearly with max_u64
.
For large maximums, segmented_eratosthenes()
is a better choice.
prime_sieve()
can be used to choose between the two automatically.
Panics
Panics if max_u64
cannot be cast into a usize
.
Can panic if max_u64
is so large that not enough
memory can be allocated for the sieve.
Examples
use reikna::prime::atkin; assert_eq!(atkin(20), vec![2, 3, 5, 7, 11, 13, 17, 19]);