Sir in this question we have to use prime sieve ?? Plz Check My code and help me if there is any errors thank you …
Code :-#include
using namespace std;
bool isPrime(int n){
if(n==1){
return false;
}
for(int j=2;j*j<=n;j++){
if(n%j==0){
return false;
}
}
return true;
}
int main(){
int t;
cin>>t;
while(t--){
int a,b;
cin>>a>>b;
int cnt=0;
for(int i=a;i<=b;i++){
if(isPrime(i)){
cnt+=1;
}
}
cout<<cnt<<endl;
}
return 0;
}