问题描述
编写一函数lcm,求两个正整数的最小公倍数。
样例输入
一个满足题目要求的输入范例。
例:
3 5
例:
3 5
样例输出
与上面的样例输入对应的输出。
例:
例:

数据规模和约定
输入数据中每一个数的范围。
例:两个数都小于65536。
例:两个数都小于65536。
import java.util.Scanner;
public class algo_153 {
static int gcd(int m,int n){
int total = m*n;
while(n>0){
int temp =m%n;
m=n;
n=temp;
}
return total/m;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int m = sc.nextInt();
int n = sc.nextInt();
System.out.println(gcd(m,n));
}
}