fn extended_gcd(a: Int, b: Int) -> GcdResult<Int> {
    // Euclid's extended algorithm
    let (mut s, mut old_s) = (Int::zero(), Int::one());
    let (mut t, mut old_t) = (Int::one(), Int::zero());
    let (mut r, mut old_r) = (b, a);

    let mut tmp = Int::zero();
    while r != 0 {
        let quotient = &old_r / &r;
        tmp.clone_from(&r); r = &old_r - &quotient * r; old_r.clone_from(&tmp);
        tmp.clone_from(&s); s = &old_s - &quotient * s; old_s.clone_from(&tmp);
        tmp.clone_from(&t); t = &old_t - &quotient * t; old_t.clone_from(&tmp);
    }

    let _quotients = (t, s); // == (a, b) / gcd

    GcdResult { gcd: old_r, c1: old_s, c2: old_t }
}
/// Calculate greatest common divisor and the corresponding coefficients.
Calculate greatest common divisor and the corresponding coefficients.
Calculate greatest common divisor and the corresponding coefficients .
fn extended_gcd(a: Int, b: Int) -> GcdResult<Int> {
    // Euclid's extended algorithm
    let (mut s, mut old_s) = (Int::zero(), Int::one());
    let (mut t, mut old_t) = (Int::one(), Int::zero());
    let (mut r, mut old_r) = (b, a);
    let mut tmp = Int::zero();
    while r != 0 {
        let quotient = &old_r / &r;
        tmp.clone_from(&r); r = &old_r - &quotient * r; old_r.clone_from(&tmp);
        tmp.clone_from(&s); s = &old_s - &quotient * s; old_s.clone_from(&tmp);
        tmp.clone_from(&t); t = &old_t - &quotient * t; old_t.clone_from(&tmp);
    }
    let _quotients = (t, s); // == (a, b) / gcd
    GcdResult { gcd: old_r, c1: old_s, c2: old_t }
}
fn extended_gcd ( a : Int , b : Int ) -> GcdResult < Int > { // Euclid's extended algorithm let ( mut s , mut old_s ) = ( Int :: zero ( ) , Int :: one ( ) ) ; let ( mut t , mut old_t ) = ( Int :: one ( ) , Int :: zero ( ) ) ; let ( mut r , mut old_r ) = ( b , a ) ; let mut tmp = Int :: zero ( ) ; while r != 0 { let quotient = & old_r / & r ; tmp . clone_from ( & r ) ; r = & old_r - & quotient * r ; old_r . clone_from ( & tmp ) ; tmp . clone_from ( & s ) ; s = & old_s - & quotient * s ; old_s . clone_from ( & tmp ) ; tmp . clone_from ( & t ) ; t = & old_t - & quotient * t ; old_t . clone_from ( & tmp ) ; } let _quotients = ( t , s ) ; // == (a, b) / gcd GcdResult { gcd : old_r , c1 : old_s , c2 : old_t } }
Calculate greatest common divisor and the corresponding coefficients.
Calculate greatest common divisor and the corresponding coefficients .
a
Int
b
Int