Опять валидатор придерается 😄
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));
String c = reader.readLine();
String d = reader.readLine();
int a = 0;
int b = 0;
try {
a = Integer.parseInt(c);
b = Integer.parseInt(d);
if (a <= 0 && b <= 0) {
throw new Exception();
}
}
catch (Exception e){
System.out.println(e.getStackTrace());
}
while (a != 0 && b != 0) {
if (a > b)
a = a % b;
else {
b = b % a;
}
}
int print = a + b;
System.out.println(print);
}
}