task 2 is very poorly written
please can somebody assist?
package com.codegym.task.task14.task1420;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/*
GCD
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int a;
int b;
try{
a = Math.abs(Integer.parseInt(reader.readLine()));
b = Math.abs(Integer.parseInt(reader.readLine()));
}
catch (Exception e) {
throw e;
}
int GCD = 1;
for(int i = 1; i <= a && i <=b; i++){
if(a % i==0 && b % i==0)
GCD = i;
}
System.out.println(GCD);
}
}