package com.hpu.bai;
import java.util.Scanner;
public class Common {
public int mincom(int m,int n){
int temp;int t = 0;
if(m<n){
temp = n;
n =m;
m =temp;
}
if(m%n ==0) return n;
else
return mincom(m-n,n);
}
public int maxcom(int m,int n){
return m*n/mincom(m,n);
}
public static void main(String[] args) {
Common com = new Common();
Scanner input = new Scanner(System.in);
System.out.println("此程序的目的是求两个正整数的最大公约数");
System.out.println("请输入第一个数");
int m = input.nextInt();
System.out.println("请输入第二个数");
int n = input.nextInt();
int max = com.maxcom(m,n);
int min = com.mincom(m,n);
System.out.println("m和n的最大公约数是"+max);
System.out.println("m和n的最小公倍数是"+min);
}
}
java初学者 QQ:623687677