#include
using namespace std;
bool arr[1000000]={1,1,0};
void sieve()
{
for(unsigned int p=2;p<=1000000;p++)
{if(arr[p]==0)
for(unsigned int j=p*p;j<=1000000;j+=p)
arr[j]=1;
}
//return(count_b-count_a);
}
int main()
{
sieve();
int test_cases;
cin>>test_cases;
while(test_cases–)
{ int a,b;
cin>>a>>b;
int count=0;
for(int i=a;i<=b;i++)
if(arr[i]==0)
count++;
cout<<count<<endl;
}
}
I am not understand the error in my code
Pls use prime seive optimisation in your code… You can refer to the video of it online…