题解 | #求最小公倍数#
求最小公倍数
https://www.nowcoder.com/practice/22948c2cad484e0291350abad86136c3
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int i = Math.max(a, b); for (; i <= a * b; i += Math.max(a, b)) { if (i % a == 0 && i % b == 0) { break; } } System.out.println(i); } }