fast-factor
A fast integer factorisation library for unsigned integers in Rust.
Usage
Add to your Cargo.toml:
[]
= "0.1.1"
Functions
factor(n)
Returns all factors of n, including 1 and n itself. Returns an empty vector for 0.
assert_eq!;
assert_eq!;
assert_eq!;
proper_factor(n)
Returns all factors of n, excluding n itself.
assert_eq!;
assert_eq!;
exclusive_factor(n)
Returns all factors of n, excluding both 1 and n itself.
assert_eq!;
assert_eq!;
Generics
All functions are generic over any type implementing PrimInt + Unsigned + Roots, so they work with u8, u16, u32, u64, u128, and usize.
factor;
factor;
Algorithm
Each function finds factors up to sqrt(n) and derives the complementary factors by division, giving O(sqrt(n)) time complexity.
License
MIT