```
public class Solution {
public int countPrimes(int n) {
if(n<=1)return 0;
int sum=0;
boolean mark[]=new boolean[n];
Arrays.fill(mark, true);
for(int i=2;i<n;++i) {
if(mark[i]) {
sum++;
int x=i;
while(x*i<n && x*i>=0) {
mark[x*i]=false;
x++;
}
} else {
}
}
return sum;
}
}
```

The above code gives wrong answer, but if I use

```
int x = 1
```

It is AC. I want to know why?