最大公约数 && 最小公倍数
求最小公倍数
http://www.nowcoder.com/questionTerminal/22948c2cad484e0291350abad86136c3
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 / gcd(A, B));
}
}
private static int gcd(int a, int b) {
return b == 0 ? a : gcd(b, a % b);
}
}
查看4道真题和解析
阿里云工作强度 664人发布