#include <iostream>
#include <cstring>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(NULL);
static int count[1000001];
int cnt=0;
int n=1000000;
bool prime[n+1];
memset(prime, true, sizeof(prime));
for (int p=2; p*p<=n; p++)
{
if (prime[p] == true)
{
for (int i=p*p; i<=n; i += p)
prime[i] = false;
}
}
for(int i=2;i<1000001;i++){
if(prime[i])cnt++;
count[i]=cnt;
}
int t;
cin>>t;
while(t--){
int n;
cin>>n;
if(n<5){cout<<n-1<<'\n';continue;}
cout<<n+count[n]-3<<'\n';
}
return 0;
}
Comments
Post a Comment