wrote function for modular multiplicative inverse