public class Maxyuebei {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("输入两个数:");
@SuppressWarnings("resource")
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
int b = scan.nextInt();
int m,n,t;
if(a>b) {
m = a;
n = b;
} else {
m = b;
n = a;
}
while(m%n != 0){
t = m%n;
m = n;
n = t;
}
System.out.println("最大公约数为:"+n);
}
}
最大公约数
最新推荐文章于 2024-05-20 20:16:31 发布