1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
pub fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

#[cfg(test)]
mod test_gcd {
    use crate::math::gcd::gcd;

    #[test]
    fn it_works() {
        assert_eq!(gcd(15, 5), 5);
        assert_eq!(gcd(5, 15), 5);
        assert_eq!(gcd(198, 26), 2);
        assert_eq!(gcd(26, 198), 2);
    }
}