1 package com.algorithm.java.blueBirdge; 2 3 import java.lang.reflect.Array; 4 import java.util.ArrayList; 5 import java.util.Arrays; 6 import java.util.Scanner; 7 8 public class leastCommonMultiple { 9 public static void main(String[] args){ 10 /* Scanner read =new Scanner(System.in); 11 int n=read.nextInt();*/ 12 System.out.println(ICD(1,5,9));//赋值 13 } 14 public static int ICD(int a,int b,int c){ //求最小公倍数 15 int k=getMax(a,b,c); 16 for (int i=k;;i++){ 17 if(i%a==0 && i%b==0 && i%c==0){ 18 return i; 19 } 20 } 21 } 22 public static int getMax(int a ,int b,int c){ //求最大值 23 int []aa={a,b,c}; 24 Arrays.sort(aa) ; 25 return aa[2]; 26 } 27 }
转载于:https://www.cnblogs.com/Catherinezhilin/p/8505060.html