Function ring_algorithm::gcd

source ·
pub fn gcd<T>(x: T, y: T) -> Twhere
    T: Sized + Zero + for<'x> From<<&'x T as Rem>::Output>,
    for<'x> &'x T: Rem,
Expand description

calcurate greatest common divisor

use ring_algorithm::gcd;
assert_eq!(gcd::<i32>(15, 21), 3);
assert_eq!(gcd::<i32>(14, 15), 1);
assert_eq!(gcd::<i32>(0, 42), 42);
assert_eq!(gcd::<i32>(0, 0), 0);