输入:俩个整数
输出:最小公倍数
样例:2 3
输出:6
import java.util.*;
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(same(a,b));
}
sc.close();
}
private static int same(int a,int b){
int t=a>b?a:b;
int sum=1;
int i=1;
while(!(sum%a==0&&sum%b==0)){
sum=t*i;
i++;
}
return sum;
}
}
求解立方根:
Math.cbrt(scanner.nextDouble());