Skip to main content

gcd

Function gcd 

Source
pub const fn gcd(left: i128, right: i128) -> u128
Expand description

Computes the non-negative greatest common divisor of two signed integers.

Examples found in repository?
examples/basic_usage.rs (line 7)
3fn main() -> Result<(), use_integer::IntegerError> {
4    assert_eq!(classify_sign(-42), IntegerSign::Negative);
5    assert!(is_divisible_by(42, 6)?);
6    assert!(are_coprime(35, 64));
7    assert_eq!(gcd(-54, 24), 6);
8    assert_eq!(lcm(-6, 15)?, 30);
9
10    Ok(())
11}