i have tried multiple times but failed to solve it
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner in =new Scanner(System.in);
int n=in.nextInt();
int a,b;
int count=0;
for(int j=1;j<=n;j++)
{
a=in.nextInt();
b=in.nextInt();
count=0;
for(int i=a;i<=b;i++)
{
if(prime(i)==true)
count++;
}
System.out.println(count);
}
}
public static boolean prime(int i)
{
if(i==1)
return false;
boolean g=true;
for(int p=2;p<i;p++)
{
if(i%p==0)
{
g=false;
break;
}
}
return g;
}
}