feat: update mod inv

This commit is contained in:
2025-07-18 00:15:18 +08:00
parent 6944d618d6
commit ba191de185

View File

@@ -17,6 +17,7 @@ public class ModularInv {
// a^-1 mod p
BigInteger x = a.modInverse(p);
BigInteger y = modularInv(a, p);
// a^(phi(p)-1) mod p
BigInteger z = a.modPow(Phi.phi(p).subtract(BigInteger.ONE), p);
System.out.println(Arrays.asList(a + "^-1 mod " + p, x, y, z));
if (!y.equals(x) || !y.equals(z)) {