Проверка на положительное число - есть
Целое число - тоже есть.
В чем затык?
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));
try {
int fir = (Integer.parseInt(reader.readLine()));
if (fir < 1) throw new Exception();
int sec = (Integer.parseInt(reader.readLine()));
if (sec < 1) throw new Exception();
System.out.println(gcd(fir,sec));
}
catch (Exception e){
System.out.println(e);
}
}
public static int gcd(int a, int b) {
if (b == 0) return a;
int x = a % b;
return gcd(b, x);
}
}