NPRIME - Nth Prime

Given an integer 1 <= N <= 100000, you have to print the Nth prime number.

Score is the length of your source.

Input

The input file consists of series of numbers one in each line.The input is terminated by EOF.

Output

The Nth prime number.

Example

Input: 
3
5
7
11

Output:

5
11
17
31

PS: Timit limit and test cases are modified on 05.10.2010 to encourage more short solution.

Added by::(){ :|: & };:
Date:2010-10-04
Time limit:2s-4.5s
Source limit:256B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64

hide comments
2020-07-19 18:24:42
It says my file is too long . 256 byte is enough??
2016-07-23 05:00:56
170 Bytes in C...
2016-01-18 13:38:48
Things you realize only in code golf: numbers 1, 0 are better than boolean values true, false .. writing 2*i+2 is better than (i+1)*2.. having n as limit and writing n-1 thrice will get you lesser score than having limit as n+1 and then writing n thrice .. :P
2015-04-14 09:13:44 Archit Kapoor
Yuuuhhhuuu..!! AC in one go..!! Solved it in C and did learn something really really surprising,amazing..!! Though my solution isn't the best, and with my limited knowledge of C, I can't optimize it any further. But I will try to solve this question in Python. May be I can submit a better solution.
2014-11-30 23:47:40 Minsuk Kim
lol program working perfectly fine but keep on getting TLE with python 2.7. I guess there is a way to improve it

Last edit: 2014-11-30 23:47:58
2014-11-03 08:50:28 « sudipto »
sieve has super powers.... 0.96s :)
got lots of TLE for EOF.. :/
2014-10-22 07:09:34 Malinga
should we write in the program explicitly to break on EOF ?? m getting TLE because my program is going in infinite loop without EOF(c++)..please some suggestions.
2014-10-09 22:07:52 CHANDAN KUMAR
Can anyone tell me about EOF and how i use it in this problem please tell me at this email-id
email:-chandankumar10116@gmail.com
2014-06-12 12:16:56 [Lakshman]
Why RTE with python "for l in sys.stdin:print p[int(l)]" can someone tell me.
--ans(Francky)--> Did you start with "import sys", and is your p tab large enough ?

Lakshman->Of course yes!. same code got AC for PPRIME. I have tested my code for n=100000. If I read the input with try and exception in catch block then no problem but RTE with sys.stdin. @francky if you can help me I can share my code.

Last edit: 2014-06-12 14:50:53
2013-12-12 09:29:07 Daniel
is the input a file or stdin?
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.