Can't pass second condition.
package com.codegym.task.task14.task1420;
/*
GCD
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
try {
BufferedReader reader= new BufferedReader(new InputStreamReader(System.in));
int num1 = Integer.parseInt(reader.readLine());
int num2 = Integer.parseInt(reader.readLine());
if(num1 <= 0 || num2 <= 0) throw new NumberFormatException("dsfgsd");
reader.close();
int dividend;
int divisor;
if(num1 > num2) {
dividend = num1;
divisor = num2;
} else {
dividend = num2;
divisor = num1;
}
for(int n = divisor; n > 0; n--) {
if(dividend%n == 0 && divisor%n == 0) {
System.out.println(n);
break;
}
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
}
}