pub trait Parity {
    fn even(self) -> bool;
    fn odd(self) -> bool;
}
Expand description

Determines whether a number is even or odd.

Required Methods

Determines whether a number is even.

Determines whether a number is odd.

Implementations on Foreign Types

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is even.

$f(x) = (2|x)$.

$f(x) = (\exists k \in \N \ x = 2k)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Tests whether a number is odd.

$f(x) = (2\nmid x)$.

$f(x) = (\exists k \in \N \ x = 2k+1)$.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Implementors