import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
int m = console.nextInt();
int n = console.nextInt();
int result = getCM(m, n);
System.out.println(result);
}
public static int getCM(int m, int n){
int max = Math.max(m,n);
int min = Math.min(m,n);
while(min!=0){
int temp = max%min;
max = min;
min = temp;
}
return m*n/max;
}
}
求出来最大公约数。用两数相乘除去最大公约数。



京公网安备 11010502036488号