【发布时间】:2015-07-10 04:14:54
【问题描述】:
public static void main(String[] args) {
int a = 0;
System.out.println(System.currentTimeMillis());
for(int x = 2; x <=10000; x++) {
boolean hasDivisor = false;
for(int y = 2; y < x; y++) {
if(x % y == 0) {
hasDivisor = true;
}
}
if(!hasDivisor) {
System.out.println(a);
}
}
}
}
这就是我的代码,我想让它在每次有素数时 int a 增加一,但我不知道在哪里放置 a++。我必须添加更多代码吗?
【问题讨论】: