Prime sieve problem

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
int n = cin.nextInt();
int arr[] = new int[1000005];
// System.out.print(arr[0]);
primeSieve(arr);
while(n>0){
int count = 0;
int a = cin.nextInt(), b = cin.nextInt();
for(int i = a;i<=b;i++){
if(arr[i] == 1){
count++;
}
}
System.out.println(count);
n–;
}

}
public static void primeSieve(int []p){
	for(int i = 3;i<p.length-4;i+=2){
		p[i]  = 1;
	}
	for(int i = 0;i<p.length-4;i+=2){
		if(p[i] == 1){
			for(int j = i*i; j<=1000000;j=j+i){
				p[j] = 0;
			}
		}
	}
	p[2] = 1;
	p[1] = p[0] = 0;
}

}======what’s the error in code output is always one more than expected

hi @AbhishekAhlawat1102
check your primeSieve function and modify it.

i m not able to figure out where my code is wrong so please point out the mistake and make corrections

@AbhishekAhlawat1102
i made the changes to your code

import java.util.*;

public class temp {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
int n = cin.nextInt();
int arr[] = new int[1000005];
// System.out.print(arr[0]);
primeSieve(arr);
while (n-- > 0) {
int count = 0;
int a = cin.nextInt(), b = cin.nextInt();
for (int i = a; i <= b; i++) {
if (arr[i] == 1) {
count++;
}
}

		System.out.println(count);

	}

}

public static void primeSieve(int[] prime) {
	 for(int i=2;i<prime.length;i++) 
        prime[i] = 1; 
	for(int p = 2; p*p <prime.length; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if(prime[p] == 1) 
        { 
            // Update all multiples of p 
            for(int i = p*p; i < prime.length; i += p) 
                prime[i] = 0; 
        } 
    } 
}

}