#numbers #divisor #find #natural #blazing #u128 #u32

divisors

A blazing fast library to find all divisors of a natural number

8 releases

0.2.1 Dec 16, 2019
0.2.0 Dec 16, 2019
0.1.5 Jun 25, 2019

#796 in Math

Download history 2271/week @ 2024-03-13 1865/week @ 2024-03-20 2053/week @ 2024-03-27 306/week @ 2024-04-03 125/week @ 2024-04-10 103/week @ 2024-04-17 116/week @ 2024-04-24 160/week @ 2024-05-01 102/week @ 2024-05-08 196/week @ 2024-05-15 113/week @ 2024-05-22 116/week @ 2024-05-29 220/week @ 2024-06-05 317/week @ 2024-06-12 162/week @ 2024-06-19 108/week @ 2024-06-26

819 downloads per month
Used in 3 crates

MIT license

9KB
68 lines

Divisors

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.

Example

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]
*/

Usage

Add this to your Cargo.toml:

[dependencies]
divisors = "0.2.1"

and this to your crate root:

extern crate divisors;

Documentations

cargo doc --no-deps --open

link

Benchmarks

cargo bench

Test

cargo test

Example

cargo run --release --example example

License

MIT.

Dependencies

~475KB