Topic array challanges Prime Visits

Can’t understand the basic criteria for solving question

Here is my code:

#include
using namespace std;

int main() {
int t;
cin>>t;
while(t–){
int a, b;
cin>>a>>b;
int visit = 0;
for(int i = a;i<=b;i++){
int flag = 0;
for(int j = 2; j < i; j++){
if(i%j==0){
++flag;
}
if(flag == 2)
{
++visit;
break;

            }
        }
    }
    cout<<visit<<endl;
}
return 0;

}

@Dev19 hey divyanshu use sieve of erthathones to solve this question.

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.