pub fn mod_pow(
base: impl Into<BigInt>,
exp: impl Into<BigInt>,
modulus: impl Into<BigInt>,
) -> BigIntExpand description
Modular exponentiation: base^exp mod modulus.
Returns 0 if modulus ≤ 0 or exp < 0. Works for non-negative
exponents.
§Examples
use symplex::ntheory::mod_pow;
use num_bigint::BigInt;
assert_eq!(mod_pow(2, 10, 1000), BigInt::from(24)); // 1024 mod 1000
assert_eq!(mod_pow(3, 4, 17), BigInt::from(13)); // 81 mod 17