标签:
import java.util.*;
public class S{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
int num1,num2,remainder,m,n;
System.out.print("请输入一个正整数:");
num1 = input.nextInt();
System.out.print("请再输入一个正整数:");
num2 = input.nextInt(); m = num1;
n = num2;
if(num1>num2){
remainder = num2;
}else{
remainder = num1;
}
while (!(num1 % remainder ==0 && num2 % remainder == 0)){
remainder--;
}
System.out.println("最大公约数是:"+remainder);
System.out.println("最小公倍数是:"+m*n/remainder);
}
}
标签:
原文地址:http://www.cnblogs.com/toaday/p/5295810.html