Trait nekolib::math::mod_pow::ModPow

source ·
pub trait ModPow {
    // Required method
    fn mod_pow(self, b: Self, n: Self) -> Self;
}
Expand description

冪乗。

$a^b \bmod n$ を返す。

Complexity

$O(\log(b))$ time.

Examples

use nekolib::math::ModPow;

assert_eq!(3_u64.mod_pow(14, 10), 9);
assert_eq!(2_u64.mod_pow(11, 1024), 0);
assert_eq!(0_u64.mod_pow(0, 1), 0);

Required Methods§

source

fn mod_pow(self, b: Self, n: Self) -> Self

Implementations on Foreign Types§

source§

impl ModPow for u64

source§

fn mod_pow(self, b: Self, n: Self) -> Self

source§

impl ModPow for u8

source§

fn mod_pow(self, b: Self, n: Self) -> Self

source§

impl ModPow for u128

source§

fn mod_pow(self, b: Self, n: Self) -> Self

source§

impl ModPow for u16

source§

fn mod_pow(self, b: Self, n: Self) -> Self

source§

impl ModPow for u32

source§

fn mod_pow(self, b: Self, n: Self) -> Self

source§

impl ModPow for usize

source§

fn mod_pow(self, b: Self, n: Self) -> Self

Implementors§