OFFSET
1,1
COMMENTS
LINKS
Maghraoui Abdelkader, Table of n, a(n) for n = 1..200
EXAMPLE
a(3) = 31 where the most significant digit of 31 is 3, which is the least significant digit of a(2) = 13.
MATHEMATICA
f[s_List] := Block[{lsd = Mod[s[[-1]], 10], p = 3}, While[ IntegerDigits[p][[1]] != lsd || MemberQ[s, p], p = NextPrime@ p]; Append[s, p]]; s = {11}; s = Nest[f, s, 70] (* Robert G. Wilson v, Sep 16 2015 *)
PROG
(PARI) msd(n)=(n\10^(#Str(n)-1)); l1=1; l3=1; l7=1; l9=1; q=1; lsd(n)=n%10;
t1 = vector(200); i=1; forprime(n=11, 10000, if( digits(n)[1]==1, t1[i]=n; i=i+1 ; )) ;
t3 = vector(130); i=1; forprime(n=31, 3900 , if( digits(n)[1]==3, t3[i]=n; i=i+1 ; ));
t7 = vector(130); i=1; forprime(n=71, 70000, if( digits(n)[1]==7, t7[i]=n; i=i+1 ; )) ;
t9 = vector(130); i=1; forprime(n=97, 90000, if( digits(n)[1]==9, t9[i]=n; i=i+1 ; )) ; lsd(n)=n%10;
t = vector(200);
findnextnumber(m) =
{if(lsd(m)==1, l1=t1[i1] ; i1=i1+1; return(l1); ); if(lsd(m)==3, l3=t3[i3]; i3=i3+1 ; return(l3); );
if(lsd(m)==7, l7=t7[i7] ; i7=i7+1; return(l7); ); if(lsd(m)==9, l9=t9[i9]; i9=i9+1; return(l9); ); }
i1=1; i3=1; i7=1; i9=1; j=1; s=11; for(n=1, 200, p=findnextnumber(s) ; t[j]=p; s=p; j++); for(i=1, 200, print1(t[i], ", ") )
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Maghraoui Abdelkader, Sep 16 2015
STATUS
approved