题解 | #四则运算#
求最小公倍数
http://www.nowcoder.com/practice/22948c2cad484e0291350abad86136c3
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(a*b/getMaxApp(a,b));
}
}
public static int getMin(int m,int n){
if(m>n){
return n;
}else{
return m;
}
}
public static int getMax(int m,int n){
if(m>n){
return m;
}else{
return n;
}
if(a==b){
return a;
}else{
int d = getMax(a,b)-getMin(a,b);
return getMaxApp(d,getMin(a,b));
}
}
}
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(a*b/getMaxApp(a,b));
}
}
public static int getMin(int m,int n){
if(m>n){
return n;
}else{
return m;
}
}
public static int getMax(int m,int n){
if(m>n){
return m;
}else{
return n;
}
}
//先获取最大公约数
public static int getMaxApp(int a,int b){if(a==b){
return a;
}else{
int d = getMax(a,b)-getMin(a,b);
return getMaxApp(d,getMin(a,b));
}
}
}