OFFSET
1,1
COMMENTS
Primes in which repeatedly deleting the least significant digit gives a prime at every step until a single-digit prime remains. The sequence ends at a(83) = 73939133 = A023107(10).
The subsequence which consists of the following "chain" of consecutive right truncatable primes: 73939133, 7393913, 739391, 73939, 7393, 739, 73, 7 yields the largest sum, compared with other chains formed from subsets of this sequence: 73939133 + 7393913 + 739391 + 73939 + 7393 + 739 + 73 + 7 = 82154588. - Alexander R. Povolotsky, Jan 22 2008
Can also be seen as a table whose n-th row lists the n-digit terms; row lengths (0 for n >= 9) are given by A050986. The sequence can be constructed starting with the single-digit primes and appending, for each p in the list, the primes within 10*p and 10(p+1), formed by appending a digit to p. - M. F. Hasler, Nov 07 2018
REFERENCES
Roozbeh Hazrat, Mathematica: A Problem-Centered Approach, Springer London 2010, pp. 86-89
LINKS
Jens Kruse Andersen, Table of n, a(n) for n = 1..83 (The full list of terms, taken from link below)
Jens Kruse Andersen, Right-truncatable primes
I. O. Angell and H. J. Godwin, On Truncatable Primes, Math. Comput. 31, 265-267, 1977.
Patrick De Geest, The list of 4260 left-truncatable primes
R. Schroeppel, HAKMEM item 33; "Russian Doll Primes", but with a slightly different definition.
Eric Weisstein's World of Mathematics, Truncatable Prime
MAPLE
s:=[1, 3, 7, 9]: a:=[[2], [3], [5], [7]]: l1:=1: l2:=4: do for j from l1 to l2 do for k from 1 to 4 do d:=[s[k], op(a[j])]: if(isprime(op(convert(d, base, 10, 10^nops(d)))))then a:=[op(a), d]: fi: od: od: l1:=l2+1: l2:=nops(a): if(l1>l2)then break: fi: od: seq(op(convert(a[j], base, 10, 10^nops(a[j]))), j=1..nops(a)); # Nathaniel Johnston, Jun 21 2011
MATHEMATICA
max = 100000; truncate[p_] := If[PrimeQ[q = Quotient[p, 10]], q, p]; ok[p_] := FixedPoint[ truncate, p] < 10; p = 1; A024770 = {}; While[ (p = NextPrime[p]) < max, If[ok[p], AppendTo[ A024770, p]]]; A024770 (* Jean-François Alcover, Nov 09 2011, after Pari *)
eppQ[n_]:=AllTrue[FromDigits/@Table[Take[IntegerDigits[n], i], {i, IntegerLength[ n]-1}], PrimeQ]; Select[Prime[Range[3400]], eppQ] (* The program uses the AllTrue function from Mathematica version 10 *) (* Harvey P. Dale, Jan 14 2015 *)
PROG
(Haskell)
import Data.List (inits)
a024770 n = a024770_list !! (n-1)
a024770_list = filter (\x ->
all (== 1) $ map (a010051 . read) $ tail $ inits $ show x) a038618_list
-- Reinhard Zumkeller, Nov 01 2011
(PARI) {fileO="b024770.txt"; v=vector(100); v[1]=2; v[2]=3; v[3]=5; v[4]=7; j=4; j1=1; write(fileO, "1 2"); write(fileO, "2 3"); write(fileO, "3 5"); write(fileO, "4 7"); until(0, if(j1>j, break); new=1; for(i=j1, j, if(new, j1=j+1; new=0); for(k=1, 9, z=10*v[i]+k; if(isprime(z), j++; v[j]=z; write(fileO, j, " ", z); )))); } \\ Harry J. Smith, Sep 20 2008
(PARI) for(n=2, 31193, v=n; while(isprime(n), c=n; n=(c-lift(Mod(c, 10)))/10); if(n==0, print1(v, ", ")); n=v); \\ Arkadiusz Wesolowski, Mar 20 2014
(PARI) A024770=vector(9, n, p=concat(apply(t->primes([t, t+1]*10), if(n>1, p)))) \\ The list of n-digit terms, 1 <= n <= 9. Use concat(%) to "flatten" it. - M. F. Hasler, Nov 07 2018
(Python)
from sympy import primerange
p = lambda x: list(primerange(x, x+10)); A024770 = p(0); i=0
CROSSREFS
KEYWORD
nonn,base,easy,fini,full,nice,tabf
AUTHOR
STATUS
approved