package ;
import java.util.Scanner;
public class {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("input x :");
int x = in.nextInt();
System.out.print("input y :");
int y = in.nextInt();
int z = Method(x,y);
System.out.println("最大公因数 : "+z);
System.out.println("最小公倍数 : "+(x*y/z));
}
public static int Method(int x,int y){
int a,b,c;
a=x;
b=y;
while(b!=0){
c=a%b;
a=b;
b=c;
}
return a;
}
public static int multiple(int x,int y){
int z;
for(z=x;;z++){
if(z%x==0&&z%y==0){
break;
}
}
return z;
}
}
原文地址:https://www.cnblogs.com/zm7844/p/8783441.html