Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Java Find the greatest common divisor of two positive integers. The integers can be large, so you need to find a clever solution.

import static java.math.BigInteger.valueOf;
import java.math.BigInteger;

public class GCD {
  public static int compute(int x, int y) {
    return valueOf(x).gcd(valueOf(y)).intValue();
  }
}
Code language: Java (java)
Source by ao.gl #
 
PREVIOUS NEXT
Tagged: #Java #Find #greatest #common #divisor #positive #The #integers #find #clever
ADD COMMENT
Topic
Name
4+7 =