g | x | w | all
Bytes Lang Time Link
010Japt h250509T112823ZShaggy
029Juby240302T183813ZJordan
034PARI/GP240229T122858Z138 Aspe
085Python 3240227T161739ZMukundan
057Factor + math.primes.lists220109T020428Zchunes
005Vyxal220109T012052Zemanresu
008APL Dyalog Extended201223T202304Zuser
006Husk201108T172052Zuser
010Husk201010T144938ZRazetime
00405AB1E171007T192033ZDatboi
058Haskell171007T171020ZSEJPM
023Wonder170222T042434ZMama Fun
093R170221T204901ZJoseph W
055Bash + common utilities170221T210538ZDigital
006MATL170221T183816ZLuis Men
071JavaScript ES6170221T191354ZETHprodu
004Jelly170221T184539ZPurkkaKo
003Oasis170221T182449ZAdnan
016Mathematica170221T182326ZLegionMa
007Actually170221T182155Zuser4594

Japt -h, 10 bytes

Æ=Èj}iX©UÉ

Try it

Æ=Èj}iX©UÉ     :Implicit input of integer U
Æ              :Map each X in the range [0,U)
 =             :  Reassign to U
  È            :    Function taking an integer as argument
   j           :      Is prime?
    }          :    End function
     i         :    Get Nth integer that returns true, where N is
      X©       :      Logical AND of X and
        UÉ     :      U-1

J-uby, 29 bytes

:**&(:take&Prime|:last)|~:^&1

Attempt This Online!

Explanation

       :take & Prime | :last             # nth prime
:** & (                     ) | ~:^ & 1  # ...applied to 1 input times

PARI/GP, 34 bytes

f(n)={r=1;for(i=1,n,r=prime(r));r}

Attempt This Online!

Python 3, 85 bytes

p=lambda x:[i for i in range(2,5*x**x)if all(i%j for j in range(2,i))][x and~-p(x-1)]

Try it online!

Uses 0-indexing.

Factor + math.primes.lists, 57 bytes

: p ( m -- n ) [ 2 ] [ 1 - p 1 - lprimes lnth ] if-zero ;

Try it online!

Explanation

Returns the 0-indexed member of the recursively-prime prime sequence.

Vyxal, 5 bytes

1$(‹ǎ

Try it Online!

1$    # Push 1 and the input
  (   # Input times
   ‹ǎ # Decrement and get nth prime

APL (Dyalog Extended), 10 8 bytes

Saved 2 bytes thanks to Adám

⌂pco⍣⎕⊢1

Try it online!

applies the function ⌂pco (nth prime) to 1 n times (n is taken through STDIN ()).

Another previous solution, 10 bytes

⊢∘⌂pco/⍴∘2

Try it online!

⍴∘2 makes a vector of n 2's, then / reduces using the train ⊢∘⌂pco. ignores its left argument, pco finds the nth prime, given n on the right. More generally, ⊢∘f/n⍴s applies f n-1 times to s.

Husk, 6 bytes

!¡!İp2

Try it online!

Explanation:

!¡!İp2
 ¡           Make an infinite list by repeatedly applying a function
     2       Starting with 2
   İp        From the sequence of prime numbers
  !          Get the element at the given index (the previous number in the sequence)
!            Get the element at index (implicit input) in that infinite list

Husk, 10 bytes

?K2ȯ!İp₀←ε

Try it online!

A recursive function.

05AB1E, 4 bytes

ÎF<Ø

Try it online!

Explanation

ÎF<Ø
Î    # Push 0 and input
 F   # Do input times...
  <   # Decrement
   Ø  # Get the nth prime (0-indexed) with n being the top of the stack

Haskell, 58 bytes

1-indexed

f 1=2;f n=[x|x<-[2..],all((>)2.gcd x)[2..x-1]]!!(f(n-1)-1)

Try it online!

Explanation:

Uses the same 0-indexed prime-list access trick as Adnan's answer.
Essentially straight-up follows the specification otherwise.

f 1=2; -- base case
f n= -- main case
    [x|x<-[2..],all((>)2.gcd x)[2..x-1]]             -- list of all primes
    [x|x<-[2..],                                     -- consider all numbers
                               [2..x-1]              -- consider all smaller numbers
                all((>)2.gcd x)                      -- is coprime with them?
                    (>)2.                            -- 2 is greater than
                         gcd x                       -- gcd(x,lambda input)
                                        !!(f(n-1)-1) -- access the
                                                     -- f(n-1)-th 1-indexed prime

Wonder, 23 bytes

p\.{1\2@:^(- p -#0 1)1P

1-indexed. Usage:

p\.{1\2@:^(- p -#0 1)1P}; p 3

Explanation

p\.{                #. Pattern matching syntax
  1\2               #. Base case p(1)=2
  @:^(- p -#0 1)1P  #. Other cases p(n)=nthprime(p(n-1)-1)
                    #. nthprime is 0-indexed
}                   #. Trailing bracket is optional in this case

R, 98 93 bytes

5 bytes thanks to @smci

Here is a horribly inefficient recursive solution:

f<-function(m,n=1){j<-1;for(i in 1:n){j<-numbers::nextPrime(j)};a<-ifelse(m==0,j,f(m-1,j));a}

Test Output:

f(6)
[1] 127

f(10)        ### takes almost a minute... YIKES!!!
[1] 648391

Bash + common utilities, 55

Since we're doing recursive primes, here's a recursive answer:

((SHLVL-2<$1))&&primes 2|sed -n "`$0 $1`{p;q}"||echo 1

Since recursion level counting is based off the $SHLVL built-in variable, then the answer can be off if you're already a few shell levels deep. This is probably why this answer doesn't work on TIO.


If that's no good, then here's a more conventional answer:

Bash + common utilities, 58

for((i=$1;i--;));{
n=`primes 2|sed -n "$n{p;q}"`
}
echo $n

Try it online.

MATL, 6 bytes

1i:"Yq

Try it online!

Explanation

1      % Push 1
i      % Input n
:      % Range [1 2 ... N]
"      % For each (that is, do the following N times)
  Yq   %   k-th prime, where k is the input
       % End for each (implicit)
       % Display stack (implicit)

JavaScript (ES6), 71 bytes

p=(n,x=1)=>n?p(n-1,(N=y=>x?N(++y,x-=(P=z=>y%--z?P(z):z==1)(y)):y)(1)):x

Ungolfed, you have three separate recursive functions:

P=(n,x=n)=>n%--x?P(n,x):x==1
N=(n,x=1)=>n?N(n-P(++x),x):x
p=(n,x=1)=>n?p(n-1,N(x)):x

Jelly, 5 4 bytes

1 byte thanks to @Dennis.

1ÆN¡

Try it online!

Explanation

1        Starting with n = 1,
 ÆN      replace n by the nth prime
   ¡     (input) times.

Oasis, 3 bytes

The program is 0-indexed. Code:

<q2

Uses the formula: a(n) = nth_prime(a(n-1) - 1), with the base case a(0) = 2.

Code explanation:

  2   = a(0)

<     # Decrement a(n - 1) to get a(n - 1) - 1
 q    # prime(a(n - 1) - 1)

Try it online!

Mathematica, 16 bytes

Nest[Prime,1,#]&

Anonymous function. Takes a number as input and returns a number as output.

Actually, 7 bytes

1@⌠DP⌡n

Try it online!

Explanation:

1@⌠DP⌡n
1        push 1
 @       swap 1 with n
  ⌠DP⌡n  do the following n times:
   DP      decrement, prime at index