Prime Data
This library was originally meant to be a simple way of working with prime numbers and storing prime numbers in a fast and memory-efficient way.
When you import this crate into your project, you will have, by default, access to the following tools:
Let's say you want to know what are all the prime numbers between 100 and 200:
let primes = generate;
With that, you can do some cool things with it:
// You can iterate over all those prime numbers
for prime in primes.iter_all
// Therefore, you can collect them into a vector
println!;
// You don't have to iterate through all of them. Maybe you just want primes within some range
// Naturally, you can collect those into a vector too
for prime in primes.iter
// If you just want to know how many there are
println!;
// ...within a range
println!;
However, there are some handy public methods, that abstract you from the need of generating any data:
// You can verify if a number is prime
println!;
// You can count the amount of primes from 1 to some bound
println!;
Features
You'll get more functionality by including features in the dependency:
"factors"
The factors feature includes a struct and a public method for factorizing numbers.
// from some prime data...
let data = generate;
// you can factorize numbers
let factors = data.factorize;
// from that, you can retrieve the original number
println!;
// retrieve the prime factors as tuples, where each tuple is of the form
// (prime, amount) meaning prime.pow(amount)
println!;
// or alternatively, you can retrieve a list of all factors
let all_factors = factors.all_factors;
println!;
println!;
// you can also convert a u64 into its factorization
let factorized_44 = from;
println!;
// finally, if you only need to list a number's factors once,
// you can use the public method:
println!;