import java.util.Scanner;
public class **_Lcm {
static int n;
static int b[];
public static void main(String[] args) {
System.out.print("你将要输入的个数?: ");
Scanner scan = new Scanner(System.in);
n = scan.nextInt();
b = new int[n];
System.out.print("请输入数字(" + n + "个)-输入非数字结束: ");
Scanner scanner = new Scanner(System.in);
int i = 0;
while (scanner.hasNextInt()) {
int a = scanner.nextInt();
System.out.print(a + " ");
b[i] = a;
i++;
}
System.out.println("");
**(b);
lcm(b);
}
public static void lcm(int b[]) {
int max = find_max(b); // 最小公倍数不小于其中最大数
int i = 0;
do {
if (max % b[i] != 0) {
max++;
i = 0;
} else {
i++;
}
} while (i < n);
System.out.println("最小公倍数是: " + max);
}
public static int find_max(int b[]) {
int max = 0;
for (int i = 0; i < n; i++) {
if (b[i] > max) {
max = b[i];
}
}
System.out.println("最大数: " + max);// ///
return max;
}
public static void **(int b[]) {
int min = find_min(b); // 最大公约数不大与其中的最小数
int i = 0;
do {
if (b[i] % min != 0) {
min--;
i = 0;
} else {
i++;
}
} while (i < n);
System.out.println("最大公约数是: " + min);
}
public static int find_min(int b[]) {
int min = 999;
for (int i = 0; i < n; i++) {
if (b[i] < min) {
min = b[i];
}
}
System.out.println("最小数: " + min);// ///
return min;
}
}