Skip to main content

Lcm

Trait Lcm 

Source
pub trait Lcm {
    // Required method
    fn lcm(self, other: Self) -> Self;
}
Expand description

最小公倍数。

§Complexity

$O(\log(\min\{m, n\}))$ time.

§Examples

use nekolib::math::Lcm;

assert_eq!(12_u32.lcm(18), 36);
assert_eq!(13_i32.lcm(-3), -39);
assert_eq!(60_u32.lcm(90).lcm(150), 900);

assert_eq!(0_u32.lcm(0), 0);
assert_eq!(0_u32.lcm(1), 0);

Required Methods§

Source

fn lcm(self, other: 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 Lcm for i8

Source§

fn lcm(self, other: Self) -> Self

Source§

impl Lcm for i16

Source§

fn lcm(self, other: Self) -> Self

Source§

impl Lcm for i32

Source§

fn lcm(self, other: Self) -> Self

Source§

impl Lcm for i64

Source§

fn lcm(self, other: Self) -> Self

Source§

impl Lcm for i128

Source§

fn lcm(self, other: Self) -> Self

Source§

impl Lcm for isize

Source§

fn lcm(self, other: Self) -> Self

Source§

impl Lcm for u8

Source§

fn lcm(self, other: Self) -> Self

Source§

impl Lcm for u16

Source§

fn lcm(self, other: Self) -> Self

Source§

impl Lcm for u32

Source§

fn lcm(self, other: Self) -> Self

Source§

impl Lcm for u64

Source§

fn lcm(self, other: Self) -> Self

Source§

impl Lcm for u128

Source§

fn lcm(self, other: Self) -> Self

Source§

impl Lcm for usize

Source§

fn lcm(self, other: Self) -> Self

Implementors§