package Java_Beginners;
import java.util.Scanner;
/题目:输入两个正整数 m 和 n,求其最大公约数和最小公倍数。/
public class Test5 {
public static void main(String[] args) {
int a,b,c;
Scanner s=new Scanner(System.in);
System.out.println("请您输入一个正整数:");
a=s.nextInt();
System.out.println("请您再输入一个正整数:");
b=s.nextInt();
GongYueShu gys=new GongYueShu();
c=gys.GongYueShu(a, b);
System.out.println("最大公约数为:"+c);
int f=a*b/c;
System.out.println("最小公倍数为:"+f);
}
}
class GongYueShu{
public int GongYueShu(int x,int y) {
int flag;
if(x<y) {
flag=x;
x=y;
y=flag;
}
while(y!=0) {
int d=x%y;
x=y;
y=d;
}
return x;
}
}