Program to get GCD (Greatest Common Divisor) of two numbers in java
public class GCDExample {
public static void main(String[] args) {
System.out.println(gcdFinder(36, 60));
}
private static int gcdFinder(int a, int b) {
int reminder = a % b;
if (reminder == 0) {
return b;
} else {
return gcdFinder(b, reminder);
}
}
}
Comments
Post a Comment