Submission of code

My code of this program is not submitting. After compiling and getting compiled successfully, when clicking on submit, it processes and after few seconds stops.

My code:

import java.util.Scanner;

public class PrateekLovesCandy {

public static void main(String[] args) {
	
	Scanner scn=new Scanner(System.in);
	int f=0;
	while(f==0)
	{
		int T=scn.nextInt();
		if(T<=10000)
		{
			f=1;
			for(int i=1;i<=T;i++)
			{
				int count=0,j=2;
				int N=scn.nextInt();
				
				while(count!=N)
				{
				
				boolean c=true;
					for(int k=2;k<=j/2;k++)
					{
						if(j%k==0)
						{
							c=false;
							break;
						}
					}
					if(c==true)
					{
						count++;
					}
				j++;
				}
				System.out.println(j-1);
			}
		}
	}

}

}

@nida_ansari99 please check your internet connection , try submitting again and let me know

@nida_ansari99
Have u see the constraint on number of test cases, It’s quite large because for every test case you are going to find the prime numbers upto that number and at last return the last prime number found, this will cause the TLE for big test cases.

So, to overcome this problem, let’s just store your test cases in an array.
Then find the maximum number from all of the testcases.
then, Use SOE(Sieve of Eratosthenes) to find the prime number upto that number and store that an the array.
After storing, simply loop over every test case that was stored previously in an array.
Print the value of n from the array storing primes.
That’s how we need not to find the prime number for every test case.

this is because your time complexity is high. you could have observed that for each test case you need to compute nth prime number and you are computing nth prime number for each case thus high time complexity.
instead you can compute all prime number once and print it for all test cases.
step1: get all input(all test cases) in an array
step2: find max of the array, say m
step3: create an array of size m+1, say prime_array
step4: find mth prime number. so while computing mth prime number , you will be getting 1st to mth prime number all( count = 1 means 1st and count = k means kth) in a single run of loop. store all these prime numbers in prime_array, prime_array[i] = ith prime number, 1<=i<=m
(Note: Time complexity of step 4 can be further reduced using SOE method.)
step5: for all test cases t, get prime_array[t]

Thanks.