не принимает решение, у меня секунд за 5-6 всё проходит. Ещё бы, больше двух милиардов итераций цикл делает. Зато любое целое. Не понятно(
package com.javarush.task.task14.task1420;
/*
НОД
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
Integer num1 = Integer.parseInt(reader.readLine());
if (num1 <= 0) throw new Exception();
Integer num2 = Integer.parseInt(reader.readLine());
if (num2 <= 0) throw new Exception();
System.out.println(NOD(num1, num2));
}
public static Integer NOD(int a, int b) {
int nod = 0;
for (int i = 1; i < Integer.MAX_VALUE; i++) {
if (a % i == 0 && b % i == 0)
nod = i;
}
return nod;
}
}