Euclidean algorithm
Extended Euclidean algorithm.