[−][src]Trait primes::PrimeSet
Provided methods
fn len(&self) -> usize
Number of primes found so far
fn is_empty(&self) -> bool
ⓘImportant traits for PrimeSetIter<'a, P>fn generator(&mut self) -> PrimeSetIter<Self>
Iterator over all primes not yet found
ⓘImportant traits for PrimeSetIter<'a, P>fn iter(&mut self) -> PrimeSetIter<Self>
Iterator over all primes, starting with 2. If you don't care about the "state" of the
PrimeSet
, this is what you want!
fn iter_vec(&self) -> Iter<u64>
Iterator over just the primes found so far
fn find(&mut self, n: u64) -> (usize, u64)
Find the next largest prime from a number
Returns (idx, prime)
Note that if n
is prime, then the output will be (idx, n)
fn is_prime(&mut self, n: u64) -> bool
Check if a number is prime
Note that this only requires primes up to n.sqrt()
to be generated, and will generate
them as necessary on its own.
fn find_vec(&self, n: u64) -> Option<(usize, u64)>
Find the next largest prime from a number, if it is within the already-found list
Returns (idx, prime)
Note that if n
is prime, then the output will be (idx, n)
fn get(&mut self, index: usize) -> u64
Get the nth prime, even if we haven't yet found it
fn prime_factors(&mut self, n: u64) -> Vec<u64>
Get the prime factors of a number, starting from 2, including repeats