что не так?
package com.javarush.task.task14.task1420;
/*
НОД
*/
import java.util.*;
public class Solution {
public static void main(String[] args) throws Exception {
Scanner scn = new Scanner(System.in);
int a = scn.nextInt();
if (a<0){
throw new Exception();
}
int b = scn.nextInt();
if(b<0){
throw new Exception();
}
int nod = 0;
int min;
int max;
ArrayList <Integer> list = new ArrayList<>();
if((a-b)>0){
max=a;
min=b;
}
else {
max = b;
min=a;
}
for (int i = 1; i<=min; i++) {
list.add(i);
}
Collections.sort(list);
Collections.reverse(list);
for(int i =0; i<list.size();i++) {
// System.out.println(list.get(i));
}
for (int i = 0; i<min;i++){
int l = list.get(i);
if(min%l==0 && max%l==0){
nod = l;
break;
}
}
System.out.println(nod);
}
}