Prime visit (time limit issue in 1st test case)

#include
using namespace std;
int main(){
int n,a,b;//sum=0;
cin>>n;
while(n>0){
cin>>a>>b;
int y=a;
int sum=0;
while(y<=b){
int z=2;
while(z<y){
if(y%z==0){
break;
}
z=z+1;
}
if(z==y){
sum=sum+1;
}
y=y+1;
}
cout<<sum<<endl;
n=n-1;
}
return 0;
}

Hi Saksham, I have seen your code.
First, for the next time,
Please share your code link properly by saving the code on online coding blocks IDE and share the link of your question with it as well.

Your question is showing perfect solution for all the test cases,
But it is taking too long to submit under Hacker Blocks Time Limit.

So Can you think of any approach where you can optimise your solution & reduce it’s time.
Then you will be able to submit your code definitely without any errors.

If you have any other doubts, please feel free to ask again !

1 Like

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.