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