Struct primal_slowsieve::Primes [] [src]

pub struct Primes { /* fields omitted */ }

Stores information about primes up to some limit.

This uses at least limit / 16 + O(1) bytes of storage.

Methods

impl Primes
[src]

Construct a Primes via a sieve up to at least limit.

This stores all primes less than limit (and possibly some more), allowing for very efficient iteration and primality testing below this, and guarantees that all numbers up to limit^2 can be factorised.

The largest number stored.

Check if n is prime, possibly failing if n is larger than the upper bound of this Primes instance.

Iterator over the primes stored in this map.

Factorise n into (prime, exponent) pairs.

Returns Err((leftover, partial factorisation)) if n cannot be fully factored, or if n is zero (leftover == 0). A number can not be completely factored if and only if the prime factors of n are too large for this sieve, that is, if there is

  • a prime factor larger than U^2, or
  • more than one prime factor between U and U^2

where U is the upper bound of the primes stored in this sieve.

Notably, any number between U and U^2 can always be fully factored, since these numbers are guaranteed to only have zero or one prime factors larger than U.

Trait Implementations

impl Debug for Primes
[src]

Formats the value using the given formatter.