def extended_gcd(a, b):
old_s, s = <NUM_LIT:1>, <NUM_LIT:0><EOL>old_t, t = <NUM_LIT:0>, <NUM_LIT:1><EOL>old_r, r = a, b<EOL>while r != <NUM_LIT:0>:<EOL><INDENT>quotient = old_r / r<EOL>old_r, r = r, old_r - quotient * r<EOL>old_s, s = s, old_s - quotient * s<EOL>old_t, t = t, old_t - quotient * t<EOL><DEDENT>return old_s, old_t, old_r<EOL>
Extended GCD algorithm.
    Return s, t, g
    such that a * s + b * t = GCD(a, b)
    and s and t are co-prime.