public class Solution {

public int countPrimes(int n) {

```
int primes=0;
for(int i=2; i<n;i++)
{
int count = 1;
for(int j=2;j<=i;j++)
{
if(i==j)
count++;
else if(i%j ==0 && i!=j)
break;
else
count++;
}
if(count == i)
primes++;
}
return primes;
}
```

}