MathHelper { public static BigInteger inverseMod(BigInteger a, BigInteger p) { if (!gcd(a, p).equals(BigInteger.ONE)) { throw new RuntimeException("does not exist"); } BigInteger b = extendedEuclid(a, p).b; while (b.compareTo(BigInteger.ZERO) < 0) { b = b.add(p); } return b; } private  MathHelper(); static BigInteger intfloordiv(BigInteger c, BigInteger d); static BigInteger intceildiv(BigInteger c, BigInteger d); static int intfloordiv(int c, int d); static int intceildiv(int c, int d); static BigIntegerTripple extendedEuclid(BigInteger u, BigInteger v); static BigInteger gcd(BigInteger u, BigInteger v); static BigInteger inverseMod(BigInteger a, BigInteger p); static BigInteger CRT(BigInteger[] congs, BigInteger[] moduli); static BigInteger CRT(List<BigInteger> congs, List<BigInteger> moduli); static BigInteger bigIntSqRootFloor(BigInteger x); static BigInteger bigIntSqRootCeil(BigInteger x);  }
@Test public void testInverseMod() { }