import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
int t = cin.nextInt();
while(t>0){
int n = cin.nextInt(), m = cin.nextInt(),c =0;
for(int i = n;i<=m;i++){
int count = 0;
for(int j = 1;j<=n;j++){
if(i%j == 0){
count++;
}
}
if(count==2){
c++;
}
}
System.out.println©;
t–;
}
}
}======what’s the error in code
Problem prime visits
You are not supposed to check factors from 1 to n for each i. Instead check till i. Or better till sqrt(i) . Also you could use Sieve of Eratosthenes in case you get TLE
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.