I am unable to solve prime visit problem

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;
}

}

just add if(i==0) return false; condition in boolean prime function

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.