What is error in my code

my code compilation is successful. but on submission my all test cases are failed

import java.util.Arrays;
import java.util.Scanner;

public class PrimePRattek {

public static void main(String[] args) {
	// TODO Auto-generated method stub
	Scanner scn = new Scanner(System.in);
	int n = scn.nextInt();
	int [] arr = new int[n];
	for(int i=0;i<arr.length;++i)
	 {
		 arr[i] = scn.nextInt();
	 }
	for(int i=0;i<arr.length;++i)
	 {
		int d = rprime(arr[i]);
		 System.out.println(d);
	 }
   
}

public static int rprime(int n)
{
boolean [] prime = new boolean[1000001];
Arrays.fill(prime, true);
prime[0]= prime[1]=false;
for(int table=2; tabletable<=1000000;++table)
{
if(prime[table])
{
for(int multi =2; table
multi<=1000000;++multi)
{
prime[multi*table] = false;
}
}
}
int count =0;
int index =0;
int i=0;
while(count<n)
{
if(prime[i])
{
index=i;
count++;
}
i++;
}
return index;
}
}

Hey @arnav_2902
here’s my suggestion to you. While doing these kinds of questions try to minimize the redundant operations.

Here it is calculating primes.
Think if T is like 10^4 and n is 10^6 and in worst case each of the test cases has very large value so you will be computing primes again and again and that will give you a TLE.

So precompute the primes once upto the given constraints, you will be good to go
and increase the prime array , you need to print 10^6th prime