我是Java的初学者。我被要求编写一个程序来查找用户输入的两个数字的 GCD。我试过了,但没有输出,如何解决?
import java.util.Scanner;
public class myclass {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
int b = scan.nextInt();
if (a < b) {
for (int c = a; c < 0; c--) {
if (a % c == 0 && b % c == 0) {
System.out.print(c);
}
}
if (b < a) {
for (int c = b; c < 0; c--) {
if (b % c == 0 && a % c == 0) {
System.out.print(c);
}
}
}
}
}
}