Add modular inverse algorithm