public static void main(String[] args) { int total = 1; for (int i = 2; i < 100000; i++) { int j; for (j = 2; j < (int) (Math.sqrt(i) + 1); j++) { if (i % j == 0) { break; } } if (j > (int) Math.sqrt(i)) { total = total * j; if (total == i) { System.out.print(i + " "); } } } }好象只有2可以这样吧。没发现其它的了
public static void main(String[] args)
{
int total = 1;
for (int i = 2; i < 100000; i++)
{
int j;
for (j = 2; j < (int) (Math.sqrt(i) + 1); j++)
{
if (i % j == 0)
{
break;
}
}
if (j > (int) Math.sqrt(i))
{
total = total * j;
if (total == i)
{
System.out.print(i + " ");
}
}
}
}好象只有2可以这样吧。没发现其它的了