can you tell me the logic to write an efficient code for this problem
my code is-
#include
using namespace std;
bool checkprime(int num)
{
int i;
for(i=2;i<num;i++)
{
if(num%i==0)
{
return false;
}
}
return true;
}
int main() {
int t;
cin>>t;
while(t>0)
{
long long int a,b;
cin>>a>>b;
int i,j,count=0;
for(i=a;i<=b;i++)
{
if(i==1)
{
continue;
}
if(checkprime(i))
{
count++;
}
}
cout<<count<<endl;
t–;
}
return 0;
}