Struct comlib_math::PrimeSieve [−][src]
pub struct PrimeSieve(_);Expand description
Sieve of Eratosthenes.
Sieve of Eratosthenes can be quickly used to determine whether a number is a prime and to find out its prime factorization.
Time complexity
The construction of the sieve takes O(n log log n) time. After this checking whether a number is a prime takes O(1) time and finding the factorization takes O(log n) time.
Implementation details
Internally the sieve stores for each index the largest prime which divides the corresponding value. For 0 and 1 the sieve stores 0 as neither is divisible by any prime.
Implementations
Constructs a new PrimeSieve.
Takes O(n log log n) time.
Factorizes the given number into its prime factors.
Returns the factors as pairs indicating the prime and the number of times its present in the factorization. The factorization is ordered in increasing order by the prime.
Turns the sieve into raw vector telling the largest prime divisor for each index.