This is the Extended Euclid algorithm : it tell you the PGCD between two numbers very fast AND he gives you the the coefficients of Bézout's identity