PPRIME - PPrimes

no tags 


N is a prime number if it has no positive divisors other than 1 and N. Prime numbers in sorted arrangement will a prime sequence.

First 10 primes of this sequence are 2,3,5,7,11,13,17,19 and 23 [Note: 1 is not prime]

Here we can say that 2 is 1st prime [Since it is at 1st location in the sequence]
3 is 2nd prime
5 is 3rd prime and so on…

PPrime is a number which is at a prime position in the above prime sequence. Eg. 2 is a Prime but not a PPrime because it is at position 1 in the prime sequence, which is not a prime position (as 1 is not prime). However 3 is a PPrime because it is at position 2, which is a prime position (as 2 is prime).

Your task is to simply print the first 10,000 PPrimes. The twist here is that you have to do so using the shortest possible code. Shorter the code, better the score.

Input
No Input

Output
Print first 10,000 PPrimes separated by a space

Scoring
Shortest code wins ;)


hide comments
dwij28: 2016-01-18 16:24:43

Also please change the source limit to something strict.. In the rankings there is an accepted solution that has 41513 bytes .. Ridiculous brute force.. I hope someone like Sir Francky or Sir Mitch will notice this and the needful ..

=(Francky)=> Such a solution is worth 0.00points, so it's not an issue.

Last edit: 2017-02-14 23:38:09
dwij28: 2016-01-18 14:20:24

Had to do it in C/C++.. Sieve of Eratosthenes results in a TLE in python 2.x ?? I can't think of any standard algorithm to find prime numbers which is fast and concise at the same time.. Maybe the problem is the time python takes to print 10000 numbers.. :/

Last edit: 2016-01-18 15:41:22

Added by:Manish Singh Bisht
Date:2014-04-15
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64