Skip to main content

ModPow

Trait 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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ModPow for u8

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 u64

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 usize

Source§

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

Implementors§