gcd

Function gcd 

Source
pub fn gcd<R>(a: El<R>, b: El<R>, ring: R) -> El<R>
Expand description

Finds a greatest common divisor of a and b.

The gcd of two elements a, b in a euclidean ring is the (w.r.t divisibility) greatest element that divides both elements, i.e. the greatest element (w.r.t. divisibility) g such that g | a, b.

Note that this function always uses the euclidean algorithm to compute the gcd. In most cases, it is instead recommended to use PrincipalIdealRing::ideal_gen(), which uses a ring-specific algorithm to compute the gcd (which will of course be gcd() in some cases).

In general, the gcd is only unique up to multiplication by units. For integers, the function signed_gcd() gives more guarantees.