import java.util.*;publicclassMain{publicstaticvoidmain(String[] args){
Scanner sc =newScanner(System.in);
System.out.println("输入第一个正整数:");int m = sc.nextInt();
System.out.println("输入第二个正整数:");int n = sc.nextInt();if(m <n){int temp = m;
m = n;
n = temp;}//最大公约数for(int i = n;i>=1;i--){if(m % i ==0&& n % i ==0){
System.out.println("最大公约数:"+ i);break;//一旦在循环中使用break,退出循环}}//最小公倍数for(int i = m;i<=m*n;i++){if(i % m ==0&& i % n ==0){
System.out.println("最大公倍数:"+i);break;}}}}