RosettaCodeData/Task/Greatest-common-divisor/Java/greatest-common-divisor-6.java

7 lines
150 B
Java

public static long gcd(long a, long b){
if(a == 0) return b;
if(b == 0) return a;
if(a > b) return gcd(b, a % b);
return gcd(a, b % a);
}