What's wrong? не понимаю ,наверное из за break?.
package com.javarush.task.task14.task1420;
import java.util.Scanner;
/*
НОД
*/
public class Solution {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
if (a <= 0 || b <= 0 || a % 1 != 0 || b % 1 != 0) {
throw new Exception();
}
for(int i=a;i>1;i--){
if(a%i==0){
if(b%i==0){
System.out.println(i);
break;
}
}
}
}
}