Deeppak and primes-number theory

I am getting TLE on this problem…my submission:

question:
DEEPAK AND PRIMES
Deepak is learning Sieve of Eratosthenes, He is stuck somewhere. Help him printing prime numbers.

Input Format:
Single line containing integral value n.

Constraints:
1<=n<=5000000

Output Format
Integral value denoting nth prime number.

Sample Input
1

Sample Output
2

hi @kumar_sunny , your is giving TLE because you are running loop from 3 to x and in each iteration you are again iterating x operation which will result in O(x^2) operations thus giving TLE which is not how seive of erastothenes works . but apart from TLE the logic you are using is not right .
Here i have corrected your : https://ide.codingblocks.com/s/188258
In case of any doubt feel free to ask :slight_smile:
if you got the answer mark your doubt as resolved

still getting wrong answer on 3 test cases:

submission: https://ide.codingblocks.com/s/188281

@kumar_sunny hey you have use simple seive ,as range of integer n is large so you have to use segmented sieve for this ,try segmented seive for this question.