pub fn power<T>(a: T, p: u64) -> T where
    T: Sized + One + for<'x> MulAssign<&'x T> + for<'x> From<<&'x T as Mul>::Output>,
    for<'x> &'x T: Mul
Expand description

calcurate $a^p$ with exponentiation by squaring

use ring_algorithm::power;
assert_eq!(power::<i32>(2, 16), 65536);