Small Rust library for calculating greatest common divisor crates.io/crates/gcd
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add doc examples.

+12
+12
src/lib.rs
··· 3 3 pub trait Gcd { 4 4 /// Determine [greatest common divisor](https://en.wikipedia.org/wiki/Greatest_common_divisor) 5 5 /// using the [Euclidean algorithm](https://en.wikipedia.org/wiki/Euclidean_algorithm) 6 + /// 7 + /// # Examples 8 + /// 9 + /// ``` 10 + /// use gcd::Gcd; 11 + /// 12 + /// assert_eq!(0, 0u8.gcd(0)); 13 + /// assert_eq!(10, 10u8.gcd(0)); 14 + /// assert_eq!(10, 0u8.gcd(10)); 15 + /// assert_eq!(10, 10u8.gcd(20)); 16 + /// assert_eq!(44, 2024u32.gcd(748)); 17 + /// ``` 6 18 fn gcd(self, other: Self) -> Self; 7 19 } 8 20