Returns the multiplicative inverse of x mod n, where n is a prime.
int multiplicativeInverseOfPrime(int x, int n) { return expMod(x, n - 2, n); }