Prime visits test case 1 is failing

#include
using namespace std;
int main() {
int t;
cin>>t;
while(t>0)
{
int u=0;
int a,b;
cin>>a>>b;
int c=a;
while(c<=b)
{
int j=2;
if(c<=3)
{u=2;
}
while(j<=c/2)
{
if (c%j==0)
{
break;
}
else if(j==c/2)
{
u=u+1;
break;
}
j=j+1;
}
c=c+1;
}
cout<<u<<endl;
t=t-1;
}
return 0;
}

Find all the prime numbers using seive of erathones and then check with each pair whether their multiplicaiton is within the range or not. In this way you will only be enumerating the prime numbers which are very less comparable to the range itself.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.