DWITE '10 R4 #2 - Primal Numbers
View as PDFDWITE Online Computer Programming Contest, January 2011, Problem 2
Math sure likes their prime numbers, those with only two factors,  and itself. 
 are the first four prime numbers, written in a sequence (numbers following each other). We've made up a new sequence of numbers, primal numbers that are based on the values of the prime numbers sequence.
The st primal number is the value that is in the position #(value of the 
st prime) in the prime sequence. That is, the 
st prime is 
, and the prime number in 
nd position is 
, so the 
st primal number is 
.
The nd primal number is in position #(value of 
nd prime) in the prime sequence. 
nd prime is 
, and the 
rd prime is 
; so the 
nd primal number is 
. The sequence continues in the same pattern; 
 are the first four primal numbers.
The input will contain 5 lines, integers .
The output will contain 5 lines, each the th primal number.
Note: think about performance for large values of . The 
th prime number is 
, so you'd need the 
th prime number to figure out what the 
th primal number is.
Sample Input
4
24
8
1
15
Sample Output
17
461
67
3
211
Problem Resource: DWITE
Comments