Implementation of Fermat's primality test
问题 Who wants to help me with my homework? I'm try to implement Fermat's primality test in Java using BigIntegers. My implementation is as follows, but unfortunately it doesn't work. Any ideas? public static boolean checkPrime(BigInteger n, int maxIterations) { if (n.equals(BigInteger.ONE)) return false; BigInteger a; Random rand = new Random(); for (int i = 0; i < maxIterations; i++) { a = new BigInteger(n.bitLength() - 1, rand); a = a.modPow(n.subtract(BigInteger.ONE), n); if (!a.equals