标签:i++ less highlight numbers log new logs ntp script
Description:
Count the number of prime numbers less than a non-negative number, n.
动归来做,
public int countPrimes(int n) {
boolean[] notPrime = new boolean[n];
int ans = 0;
if (n < 2) {
return ans;
}
for (int i = 2; i < n; i++) {
if (!notPrime[i]) {
ans++;
for (int j = 2; i * j < n; j++) {
notPrime[i * j] = true;
}
}
}
return ans;
}
标签:i++ less highlight numbers log new logs ntp script
原文地址:http://www.cnblogs.com/apanda009/p/7609098.html