- class LowMul {
-
- private int A, B;
-
- public int get(int a, int b) {
- for (int i = Math.max(a, b);; i++) {
- A = a;
- B = b;
- if (accept(i)) {
- return i;
- }
- }
- }
-
- private boolean accept(int n) {
- return n % A == 0 && n % B == 0;
- }
-
- public static void main(String[] args) {
-
- LowerCommonMultiple lcm = new LowerCommonMultiple();
- int test = lcm.get(12, 18);
- System.out.println(test);
- }
-
- }
复制代码 |