求最大公约数和最小公倍数

import java.util.scanner;
public class Test {
public static int fun(int a ,int b){
int c;
c = a % b;
while(c > 0){
a = b;
b = c;
c = a % b;
}
return(b);
 }
public static void main(String args[]){
int a,b,temp; int m;
Scanner sn = new Scanner(System.in 
);
a =sn.nextInt();
b =sn.nextInt();
if(a<b){ temp = a;
a = b;
b = temp;
}
m = fun(a,b);
System.out.println("最大公约数:" + m);
System.out.println("最小公倍数:" + (a*b)/m);
}
}
原文地址:https://www.cnblogs.com/kongdexiu-13/p/8783422.html