public static void algorithmOne(int n){
long startTime = System.currentTimeMillis();
search:
for (int possiblePrime = 2; possiblePrime <= n; possiblePrime++){
for (int divisor = 2; divisor < possiblePrime; divisor++)
if ( possiblePrime%divisor == 0 && possiblePrime != divisor )
continue search;
System.out.println(possiblePrime);
}
long endTime = System.currentTimeMillis();
System.err.println(endTime - startTime);
}
这是一种查找素数的方法,我无法弄清楚为什么我没有达到“System.err.println(endTime - startTime);” 线。