pub struct Comb { /* private fields */ }
Expand description
A struct for pre-calculating factorials and their modular inverses, useful for efficient combination and permutation calculations under mod.
Implementations§
Source§impl Comb
impl Comb
Sourcepub fn new(mod_value: u64, max_fact: usize) -> Comb
pub fn new(mod_value: u64, max_fact: usize) -> Comb
Creates a new Comb
instance, pre-calculating factorials and their
modular inverses up to max_fact
.
This pre-computation allows for fast calculation of combinations and permutations
modulo mod_value
.
§Arguments
mod_value
- The modulus to use for calculations.max_fact
- The maximum number for which factorials and inverse factorials will be pre-calculated. This determines the range ofn
that can be used innCr
andnPr
without requiring further calculations.
§Panics
Panics if modulus is not prime.
Auto Trait Implementations§
impl Freeze for Comb
impl RefUnwindSafe for Comb
impl Send for Comb
impl Sync for Comb
impl Unpin for Comb
impl UnwindSafe for Comb
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more