8 个版本
0.2.1 | 2019 年 12 月 16 日 |
---|---|
0.2.0 | 2019 年 12 月 16 日 |
0.1.5 | 2019 年 6 月 25 日 |
#848 in 数学
578 每月下载次数
用于 3 crates
9KB
68 行
除数
这是一个快速的 Rust 库,用于找到自然数的所有除数。这个库与 u8, u16, u32, u64, u128 和 usize 类型一起工作。
示例
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]
*/
用法
将此添加到您的 Cargo.toml
[dependencies]
divisors = "0.2.1"
并将此添加到您的 crate 根目录
extern crate divisors;
文档
cargo doc --no-deps --open
基准测试
cargo bench
测试
cargo test
示例
cargo run --release --example example
许可证
MIT.
依赖项
~475KB