#include
using namespace std;
int main() {
int T;
long long n;
cin >> T;
int primes[] = {2,3,5, 7, 11, 13, 17,19};
int k = sizeof(primes)/ sizeof(int);
while(T–)
{
int count = 0;
cin >> n;
for(int i = 2 ; i < n; i++)
{
for(int j = 0 ; j < k ;j++)
{
if( i%primes[j]==0)
{
count++;
break;
}
}
}
count++;
cout << count << endl;
}
return 0;
}
Whats wrong in this code ( Not so easy math)
You need to Optimize your code.
Hint->Inclusion Exclusion Principle
Hi
refer to this post