public class MyClass {
static int gcd(int a, int b) {
return b == 0 ? a : gcd(b, a % b);
}
public static void main(String args[]) {
int a = 12, b = 20, gcd = 0;
System.out.format("The GCD of %d and %d is: %d\n", a, b, gcd(a, b));
}
}
/*
run:
The GCD of 12 and 20 is: 4
*/