题解 | #求最小公倍数#
求最小公倍数
https://www.nowcoder.com/practice/22948c2cad484e0291350abad86136c3
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNextInt()) { int a = in.nextInt(); int b = in.nextInt(); int ab = gcd(a, b); System.out.println(a * b / ab); } } public static int gcd(int a, int b) { //return b == 0 ? a : gcd(b, a % b); int r = 0; while (b > 0) { r = a % b; a = b; b = r; } return a; } }
#学生时代让我难忘的事#