Description Of BigInteger: gcd(BigInteger val)
The java.math.BigInteger.gcd(BigInteger val) returns a BigInteger whose value is the greatest common divisor of abs(this) and abs(val). It returns 0 if this==0 && val==0.BigInteger.floatValue() This method returns a BigInteger whose value is GCD(abs(this), abs(val))
Code Example Java BigInteger
import java.math.BigInteger;
public class BigIntegerExam {
public static void main(String[] args) {
// assign values to bi1, bi2
BigInteger bi1 = new BigInteger("24");
BigInteger bi2 = new BigInteger("32");
// assign gcd of bi1, bi2 to bi3
BigInteger bi3 = bi1.gcd(bi2);
System.out.println(bi3); // output 8
}
}
ไม่มีความคิดเห็น :
แสดงความคิดเห็น