已知:2520是可以被1到10中的每一个数除而没有任何余数的最小数。
求:能被1到20之间的所有数字整除的最小正数是多少? 232792560
public static int getMinPositiveNum(int in_num) { for (int n = in_num; ; n++) { int cnt = 0; for (int i = 1; i <= in_num; i++) { if (n % i == 0) { cnt++; } } if (cnt == in_num) { System.out.println(n + " is the smallest positive number that is evenly divisible by all of the numbers from 1 to " + in_num); return n; } } } public static void main(String[] args) { getMinPositiveNum(20); }