Prime Visits
#include<bits/stdc++.h>
#include
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
int a,b;
cin>>a>>b;int cnt=0;int cnt1=0;
for(int i=a;i<=b;i++)
{
int x = i;
cnt=0;
for(int j=2;j<=sqrt(x);j++)
{
if(x%j==0)
cnt++;
}
if(cnt==0 && i>1)
cnt1++;
}
cout<<cnt1<<endl;
}
return 0;
}
i was getting tle can you please help me how to optimize my code.