В чем может быть причина? Решал согласно алгоритму Евклида...
package com.javarush.task.task14.task1420;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/*
НОД
*/
public class Solution {
public static void main(String[] args) throws Exception {
Scanner console = new Scanner(System.in);
int a = Integer.parseInt(console.nextLine());
int b = Integer.parseInt(console.nextLine());
int result = Integer.MIN_VALUE;
if (a > b){
result = getNOD(a,b);
} else if(a < b) {
result = getNOD(b,a);
} else {
result = a;
}
System.out.println(result);
}
public static int getNOD(int value1, int value2) {
if (value1 < 1 || value2 < 1){
throw new IllegalArgumentException();
}
int a = value1;
int b = value2;
int division = -1, remainder = -1;
while (a%b != 0){
division = a/b;
remainder = a%b;
a = b;
b = remainder;
}
return remainder;
}
}