pub fn mul_pow_mod<T, U>(a: T, base: T, power: U, modulo: &T) -> T
Expand description
$a\cdot b^p \bmod n
$
Input: $-\text{modulo} \leq b \leq \text{modulo}
$,
c is non-negative integer.
Output: $-\text{modulo} \leq x \leq \text{modulo}
$
use modulo_n_tools::mul_pow_mod;
assert_eq!(mul_pow_mod(1, 3, 4, &5), 1);
assert_eq!(mul_pow_mod(1, 2, 5, &6), 2);
assert_eq!(mul_pow_mod(1, -2, 3, &4), 0);
assert_eq!(mul_pow_mod(1, 2, 3, &7), 1);