def extEuclidR(a, b):
    """
  extEuclidR(a, b) -> number, number, number

  A recursive implementation of the Extended Euclidean Algorithm
  used for discovering x and y in the equation:
  ax + by = d, where d is the greatest common denominator of a and b.
    """
    if b == 0:
        return (1, 0, a)
    else:
        (x, y, gcd) = extEuclidR(b, a % b)
        x, y = y, x - (y * (a / b))
        return (x, y, gcd)