Where am I making a mistake?
Code:
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = 0;
if(sc.hasNextInt())
n = sc.nextInt();
long a = 0;
long b = 0;
for(int i = 0; i < n; i++) {
if(sc.hasNextLong()) {
a = sc.nextLong();
b = sc.nextLong();
}
primeVisits(a, b);
}
}
public static void primeVisits(long a, long b) {
long count = 0;
for(long i = a; i <= b; i++) {
if(i == 1)
i++;
if(isPrime(i))
count++;
}
System.out.println(count);
}
public static boolean isPrime(long x) {
boolean flag = true;
for(long i = 2; i <= x - 1; i++) {
if(x % i == 0) {
flag = false;
}
if(flag == false)
break;
}
return flag;
}
}