multiplicative inverse using extended euclidean algorithm