i cant find a logic to do this other than this
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int pc=0;
int a,b,j,i;
cin>>a;
cin>>b;
if(a==1)
a=a+1;
for( i=a;i<=b;i++)
{
for( j=2;j<i;j++)
{
if(i%j==0)
break;
}
if(j==i)
pc++;
}
cout<<pc<<endl;
}
}
please help me in this