Function modulo_n_tools::mul_mod [−][src]
pub fn mul_mod<T>(a: &T, b: &T, modulo: &T) -> T where
for<'x> &'x T: Mul<Output = T> + Rem<Output = T>,
Expand description
$ab \bmod n
$
Input: $-\text{modulo} \leq a,\, b \leq \text{modulo}
$
Output: $-\text{modulo} \leq x \leq \text{modulo}
$
use modulo_n_tools::mul_mod; assert_eq!(mul_mod(&3, &4, &5), 2); assert_eq!(mul_mod(&2, &5, &6), 4); assert_eq!(mul_mod(&-2, &-3, &4), 2); assert_eq!(mul_mod(&2, &3, &6), 0);