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

Popular posts from this blog

Check if booleans are same

Program get max salary Female Employee in java8