Prateek Loves candy:

please explain me the solution of this question thoroughly.i am a java crux enroller and its difficult to unterstand the editorial solution to this question how are we using soe and array ,plz help me code it line by line

HI Yamini,
See in this question you cannot use SOE method because see you have to find nth prime numbers not all the prime numbers till n. in this question first take the no. of testcase and then form an array of length equal to the no. of testcase and then store each testcase in array. Now find the maximum value of element in the array of testcases. See if we find all the prime numbers till the maximum testcase and stored in the array say prime we can easily print all the required prime numbers just by iterating over the array prime. Now see all the prime numbers are odd also, a number is prime if it is not divisibe by any number till its square root except by 1 . For eg: consider 16 as one of the testcase now square root of 16 is 4 now since 16 is divisible by 2 which is less than 4 hence it is not a prime number and now consider 11 and square root of 11 is 3 if we consider int data type now since 11 is not divisible by both 2 and 3 so it is a prime number.