Trait DivisibleBy

Source
pub trait DivisibleBy<RHS = Self> {
    // Required method
    fn divisible_by(self, other: RHS) -> bool;
}
Expand description

Determines whether a number is divisible by another number.

Required Methods§

Source

fn divisible_by(self, other: RHS) -> bool

Implementations on Foreign Types§

Source§

impl DivisibleBy for i8

Source§

fn divisible_by(self, other: i8) -> bool

Returns whether a number is divisible by another number; in other words, whether the first number is a multiple of the second.

This means that zero is divisible by any number, including zero; but a nonzero number is never divisible by zero.

$f(x, m) = (m|x)$.

$f(x, m) = (\exists k \in \Z : \ x = km)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl DivisibleBy for i16

Source§

fn divisible_by(self, other: i16) -> bool

Returns whether a number is divisible by another number; in other words, whether the first number is a multiple of the second.

This means that zero is divisible by any number, including zero; but a nonzero number is never divisible by zero.

$f(x, m) = (m|x)$.

$f(x, m) = (\exists k \in \Z : \ x = km)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl DivisibleBy for i32

Source§

fn divisible_by(self, other: i32) -> bool

Returns whether a number is divisible by another number; in other words, whether the first number is a multiple of the second.

This means that zero is divisible by any number, including zero; but a nonzero number is never divisible by zero.

$f(x, m) = (m|x)$.

$f(x, m) = (\exists k \in \Z : \ x = km)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl DivisibleBy for i64

Source§

fn divisible_by(self, other: i64) -> bool

Returns whether a number is divisible by another number; in other words, whether the first number is a multiple of the second.

This means that zero is divisible by any number, including zero; but a nonzero number is never divisible by zero.

$f(x, m) = (m|x)$.

$f(x, m) = (\exists k \in \Z : \ x = km)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl DivisibleBy for i128

Source§

fn divisible_by(self, other: i128) -> bool

Returns whether a number is divisible by another number; in other words, whether the first number is a multiple of the second.

This means that zero is divisible by any number, including zero; but a nonzero number is never divisible by zero.

$f(x, m) = (m|x)$.

$f(x, m) = (\exists k \in \Z : \ x = km)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl DivisibleBy for isize

Source§

fn divisible_by(self, other: isize) -> bool

Returns whether a number is divisible by another number; in other words, whether the first number is a multiple of the second.

This means that zero is divisible by any number, including zero; but a nonzero number is never divisible by zero.

$f(x, m) = (m|x)$.

$f(x, m) = (\exists k \in \Z : \ x = km)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl DivisibleBy for u8

Source§

fn divisible_by(self, other: u8) -> bool

Returns whether a number is divisible by another number; in other words, whether the first number is a multiple of the second.

This means that zero is divisible by any number, including zero; but a nonzero number is never divisible by zero.

$f(x, m) = (m|x)$.

$f(x, m) = (\exists k \in \N : x = km)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl DivisibleBy for u16

Source§

fn divisible_by(self, other: u16) -> bool

Returns whether a number is divisible by another number; in other words, whether the first number is a multiple of the second.

This means that zero is divisible by any number, including zero; but a nonzero number is never divisible by zero.

$f(x, m) = (m|x)$.

$f(x, m) = (\exists k \in \N : x = km)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl DivisibleBy for u32

Source§

fn divisible_by(self, other: u32) -> bool

Returns whether a number is divisible by another number; in other words, whether the first number is a multiple of the second.

This means that zero is divisible by any number, including zero; but a nonzero number is never divisible by zero.

$f(x, m) = (m|x)$.

$f(x, m) = (\exists k \in \N : x = km)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl DivisibleBy for u64

Source§

fn divisible_by(self, other: u64) -> bool

Returns whether a number is divisible by another number; in other words, whether the first number is a multiple of the second.

This means that zero is divisible by any number, including zero; but a nonzero number is never divisible by zero.

$f(x, m) = (m|x)$.

$f(x, m) = (\exists k \in \N : x = km)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl DivisibleBy for u128

Source§

fn divisible_by(self, other: u128) -> bool

Returns whether a number is divisible by another number; in other words, whether the first number is a multiple of the second.

This means that zero is divisible by any number, including zero; but a nonzero number is never divisible by zero.

$f(x, m) = (m|x)$.

$f(x, m) = (\exists k \in \N : x = km)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl DivisibleBy for usize

Source§

fn divisible_by(self, other: usize) -> bool

Returns whether a number is divisible by another number; in other words, whether the first number is a multiple of the second.

This means that zero is divisible by any number, including zero; but a nonzero number is never divisible by zero.

$f(x, m) = (m|x)$.

$f(x, m) = (\exists k \in \N : x = km)$.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Implementors§