最小的两个具有两个不同质数因子的连续整数是:
14 = 2 7
15 = 3 5
最小的三个具有三个不同质数因子的连续整数是:
644 = 2² 7
23
645 = 3 5
43
646 = 2 17
19.
找出最小的四个具有四个不同质数因子的整数。它们之中的第一个是多少?
时间过长~~
import java.util.Arrays;
public class Problem47
{
public static void main(String[] args)
{
long start = System.currentTimeMillis();
System.out.print("answer: ");
howmany();
long end = System.currentTimeMillis();
System.out.print("time: ");
System.out.println(end - start);
}
static void howmany()
{
int array[] = new int[4];
int yinshu[] = new int[4];
int nu = 0;
l1 : for (int i = 14;; i++)
{
int t = i;
int index = 0;
for (int j = 2; j <= t; j++)
{
if (t % j == 0)
{
if (index == 0)
{
yinshu[0] = j;
index++;
}
else if (j != yinshu[index - 1])
{
if (index == 4)
{
index = 0;
continue l1;
}
else
{
yinshu[index] = j;
index++;
}
}
t /= j;
j--;
}
}
// System.out.println(Arrays.toString(yinshu));
if (index == 4)
{
if (nu == 0)
{
array[0] = i;
nu++;
}
else if (array[nu - 1] + 1 == i)
{
array[nu] = i;
nu++;
}
else
{
array[0] = i;
nu = 1;
}
}
if (nu == 4)
{
System.out.println(Arrays.toString(array));
break;
}
}
}
}
answer: [134043, 134044, 134045, 134046]
time: 10189