```
public class Solution {
public int CountPrimes(int n) {
System.Collections.BitArray maps = new System.Collections.BitArray(n, true);
int count=0;
if (n <= 1){
return 0;
}
for(int i=2; i < n; i++){
if (maps[i]){
count++;
}
for (int j = 2 ; i * j < n ;j++ ){
maps[i*j] = false;
}
}
return count;
}
}
```