Here's some GAP code which exhaustively enumerates all nested primes. It's a backtracking algorithm, adding a new digit at each step. It the current number is a prime, it prints it out, otherwise, throws it away.
DigitsToInt:=function(d) return Sum([1..Size(d)],i->10^(Size(d)-i)*d[i]); end;; NestPrime:=function(d) local i,k; for i in [1,3,7,9] do d:=Concatenation(d,[i]); k:=DigitsToInt(d); if(IsPrimeInt(k)) then Print(k,"\n"); NestPrime(d); fi; d:=List([1..Size(d)-1],j->d[j]); od; end;; for d in [[2],[3],[5],[7]] do k:=DigitsToInt(d); Print(k,"\n"); NestPrime(d); od;
Note that GAP's IsPrimeInt
is a deterministic primality test for $n \leq 10^{13}$, which is sufficient in this case.
Which outputs:
2 23 233 2333 23333 23339 2339 23399 233993 2339933 23399339 239 2393 2399 23993 239933 2399333 29 293 2939 29399 293999 2939999 29399999 3 31 311 3119 31193 313 3137 31379 317 37 373 3733 37337 373379 3733799 37337999 37339 373393 3739 37397 379 3793 3797 5 53 59 593 5939 59393 593933 5939333 59393339 59399 593993 599 7 71 719 7193 71933 719333 73 733 7331 7333 73331 739 7393 73939 739391 7393913 73939133 739393 7393931 7393933 739397 739399 79 797
So, yes there is a largest nested prime, and it's 73939133 (in agreement with Ross Millikan's answer and Sloane's A024770).