Euclidean algorithm
Polynomial extended Euclidean algorithm.