Crates.io | tcorp_math_mods |
lib.rs | tcorp_math_mods |
version | 0.1.0 |
source | src |
created_at | 2015-10-24 21:16:13.620886 |
updated_at | 2015-12-11 23:56:40.231265 |
description | This will be a growing collection of helpful math functions and algorythems all of which will be abstracted into generic types. |
homepage | https://github.com/thetyrelcorporation/tcorp_math_mods |
repository | https://github.com/thetyrelcorporation/tcorp_math_mods |
max_upload_size | |
id | 3298 |
size | 15,780 |
This will be a growing collection of helpful math functions and algorythems all of which will be abstracted into generic types.
Install and initialize with
extern crate tcorp_math_mods;
use tcorp_math_mods::factors;
Special thanks to Kendall at http://stackoverflow.com/questions/110344/algorithm-to-calculate-the-number-of-divisors-of-a-given-number for the fastest factorization algorithm ever. Both functions rely on a ported and slightly modified version.
There are two methods currently.
The first is number_of_factors
let x: u32 = 7;
assert_eq!(factors::number_of_factors(x), 2); // Will pass and the return type will be u32
The second function is factors_for
let x: i64 = 100;
assert_eq!(factors::factors_for(x), ); // Will pass and the return type will be Vec<i64>