dsalgo 0.3.7

A package for Datastructures and Algorithms.
Documentation
pub fn factorial<T>(n: u64) -> T
where
    T: std::ops::Mul<Output = T> + From<u64>,
{
    (1..=n).fold(1.into(), |accum, x| {
        accum * x.into()
    })
}

#[cfg(test)]
mod tests {
    #[test]
    fn test() {
        use super::*;
        use crate::{
            default_static_modular_arithmetic::Modular1_000_000_007,
            static_modular_int::StaticModularInt,
        };

        type Mint = StaticModularInt<u32, Modular1_000_000_007>;

        assert_eq!(
            factorial::<Mint>(20).value(),
            146326063
        );
    }
}