17
1
The Recursively Prime Primes is are sequence of primes such that
p(1) = 2
p(n) = the p(n-1)th prime
Here is an example of how one might calculate the 4th Recursively Prime Prime.
p(4) = the p(3)th prime
p(3) = the p(2)th prime
p(2) = the p(1)th prime
p(1) = 2
p(2) = the 2nd prime
p(2) = 3
p(3) = the 3rd prime
p(3) = 5
p(4) = the 5th prime
p(4) = 11
You should write a program or function that when given n, outputs the nth Recursively Prime Prime.
You may choose to use 0 based indexing if you wish in which case you must indicate so in your answer.
This is code-golf so the goal is to minimize your byte count.
Test Cases
1 -> 2
2 -> 3
3 -> 5
4 -> 11
5 -> 31
6 -> 127
7 -> 709
8 -> 5381
9 -> 52711
Relevant OEIS entry: OEIS A007097
You don't need the
⁸
. – Dennis – 2017-02-21T18:57:24.747@Dennis So does
¡
only accept nilads as repetitions and default to input if none are found? – PurkkaKoodari – 2017-02-21T19:15:50.780<f><n>¡
happily accepts monadic or dyadic atoms for<n>
. However, if<f>
is a nilad, something must be wrong, so it is parsed as<f>¡
instead and takes the last input (last command-line argument, STDIN is there are none) as<n>
instead. – Dennis – 2017-02-21T19:59:52.103