adding extended euclidean algorithm