pub trait Gcd<Rhs> {
    type Output;
}
Expand description

A type operator that computes the greatest common divisor of Self and Rhs.

Example

use typenum::{Gcd, Unsigned, U12, U8};

assert_eq!(<U12 as Gcd<U8>>::Output::to_i32(), 4);

Required Associated Types§

The greatest common divisor.

Implementors§

gcd(0, 0) = 0

gcd(x, 0) = x

gcd(x, y) = 2*gcd(x/2, y/2) if both x and y even

gcd(x, y) = gcd(x, y/2) if x odd and y even

gcd(x, y) = gcd(x/2, y) if x even and y odd

gcd(x, y) = gcd([max(x, y) - min(x, y)], min(x, y)) if both x and y odd

This will immediately invoke the case for x even and y odd because the difference of two odd numbers is an even number.

gcd(0, y) = y