C++ implementation of the Extended Euclidean Algorithm