import java.util.Scanner;
public class Yueshu {
public static void main(String[] args) {
int a,b,c,i;
Scanner Scan=new Scanner(System.in);
System.out.println("请输入第一个大于0的整数:");
a=Scan.nextInt();
System.out.println("请输入第二个大于0的整数:");
b=Scan.nextInt();
Scan.close();
if(a<b){
i=a;
a=b;
b=i;
}
c=a%b;
while(c!=0){
a=b;
b=c;
c=a%b;
}
System.out.println("两个整数的最大公约数为:"+b);
}
}
运行结果: