int gcdByBruteForce(int n1, int n2) {
int gcd = 1;
for (int i = 1; i <= n1 && i <= n2; i++) {
if (n1 % i == 0 && n2 % i == 0) {
gcd = i;
}
}
return gcd;
}
public class Main {
public static void main(String[] args) {
System.out.println(getGreatestCommonDivisor (25, 15));
// output is 5
}
public static int getGreatestCommonDivisor (int first, int second) {
if (first < 10 || second < 10) {
return -1;
}
int GCD = 1;
for (int i = 1; i <= first && i <= second; i++) {
if ((first % i == 0) && (second % i == 0)) {
GCD = i;
}
}
return GCD;
}
}