Crates.io | divisors |
lib.rs | divisors |
version | 0.2.1 |
source | src |
created_at | 2019-06-25 00:48:32.298206 |
updated_at | 2019-12-16 23:57:09.833025 |
description | A blazing fast library to find all divisors of a natural number. |
homepage | |
repository | https://github.com/uccidibuti/divisors |
max_upload_size | |
id | 143351 |
size | 39,466 |
A blazing fast Rust library to find all divisors of a natural number. This library works with u8, u16, u32, u64, u128 and usize types.
use std::time::{Instant};
fn main() {
let n: u128 = 934832147123321;
println!("finding divisors of {}", n);
let start_time = Instant::now();
let v = divisors::get_divisors(n);
println!("time = {:?}, divisors = {:?}", start_time.elapsed(), v);
}
/* Output:
finding divisors of 934832147123321
time = 663.484µs, divisors = [19, 5011, 63397, 95209, 154877, 1204543, 2942663, 317682367, 776088647, 6035964973, 9818737169, 14745684293, 186556006211, 49201691953859]
*/
Add this to your Cargo.toml
:
[dependencies]
divisors = "0.2.1"
and this to your crate root:
extern crate divisors;
cargo doc --no-deps --open
cargo bench
cargo test
cargo run --release --example example
MIT.