Java BigInteger is Prime isCoprime(BigInteger a, BigInteger b)

Here you can find the source of isCoprime(BigInteger a, BigInteger b)

Description

Returns true if A and B are coprime.

License

Apache License

Parameter

Parameter Description
a a parameter
b a parameter

Declaration

public static boolean isCoprime(BigInteger a, BigInteger b) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.math.BigInteger;

public class Main {
    /**//from  w  w w.ja  v  a 2  s.  c  om
     * Returns true if A and B are coprime.  A and B
     * are considered coprime if A and B share no GCD
     * other than 1.
     * 
     * @param a
     * @param b
     * @return
     */
    public static boolean isCoprime(BigInteger a, BigInteger b) {
        return a.gcd(b).equals(BigInteger.ONE);
    }
}

Related

  1. calculateMPrime(BigInteger n, byte[] message)
  2. fnvHash(final byte[] data, final BigInteger fnvOffs, final BigInteger fnvPrime, final BigInteger mod)
  3. hasSqrtModPrime(BigInteger r, BigInteger p)
  4. isBigPrime(BigInteger number)
  5. isFermatPrime(BigInteger f)
  6. isPrime(BigInteger value)
  7. primeProcessPart(BigInteger from)
  8. sqrtModPrime(BigInteger rSquare, BigInteger p)