计算 java 中两个数的互质数
Work out co-prime of two numbers in java
我有两个 BigIntegers 持有素数。
BigInteger a = BigInteger.probablePrime(16, new Random());
BigInteger b = BigInteger.probablePrime(16, new Random());
BigInteger c;
如何找到这两个 BigInteger 的互质并将其存储在 c 中;
Co-primality of integers a and b refers to the question of whether the gcd(a,b) = 1 or not. Java's BigInteger class provides the gcd
计算方法:
BigInteger c = a.gcd(b); // or equivalently b.gcd(a).
我有两个 BigIntegers 持有素数。
BigInteger a = BigInteger.probablePrime(16, new Random());
BigInteger b = BigInteger.probablePrime(16, new Random());
BigInteger c;
如何找到这两个 BigInteger 的互质并将其存储在 c 中;
Co-primality of integers a and b refers to the question of whether the gcd(a,b) = 1 or not. Java's BigInteger class provides the gcd
计算方法:
BigInteger c = a.gcd(b); // or equivalently b.gcd(a).