ScientificInteger

Trait ScientificInteger 

Source
pub trait ScientificInteger: ScientificNumber + Eq {
    // Required methods
    fn gcd(self, other: Self) -> Self;
    fn lcm(self, other: Self) -> Self;
    fn is_prime(self) -> bool;
    fn is_even(self) -> bool;
    fn is_odd(self) -> bool;
    fn mod_pow(self, exp: Self, modulus: Self) -> Self;
    fn factorial(self) -> CoreResult<Self>;
    fn binomial(self, k: Self) -> Self;
}
Expand description

A trait for integers that can be used in scientific calculations

Required Methods§

Source

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

Greatest common divisor

Source

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

Least common multiple

Source

fn is_prime(self) -> bool

Check if the number is prime

Source

fn is_even(self) -> bool

Check if the number is even

Source

fn is_odd(self) -> bool

Check if the number is odd

Source

fn mod_pow(self, exp: Self, modulus: Self) -> Self

Modular exponentiation (self^exp mod modulus)

Source

fn factorial(self) -> CoreResult<Self>

Factorial

Source

fn binomial(self, k: Self) -> Self

Binomial coefficient (n choose k)

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 ScientificInteger for i32

Source§

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

Source§

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

Source§

fn is_prime(self) -> bool

Source§

fn is_even(self) -> bool

Source§

fn is_odd(self) -> bool

Source§

fn mod_pow(self, exp: Self, modulus: Self) -> Self

Source§

fn factorial(self) -> CoreResult<Self>

Source§

fn binomial(self, k: Self) -> Self

Implementors§