login
For each natural number n: if the last digit of n is not zero and A004086(n) is prime, append A004086(n) to the sequence.
2

%I #16 Feb 17 2022 13:47:35

%S 2,3,5,7,11,31,41,61,71,13,23,43,53,73,83,17,37,47,67,97,19,29,59,79,

%T 89,101,401,601,701,211,311,811,911,421,521,821,131,331,431,631,241,

%U 541,641,941,151,251,751,461,661,761,271,571,971,181,281,881

%N For each natural number n: if the last digit of n is not zero and A004086(n) is prime, append A004086(n) to the sequence.

%C Equivalently, these are the prime numbers ordered by their reversal. - _Rémy Sigrist_, Feb 13 2022

%H Rémy Sigrist, <a href="/A104154/b104154.txt">Table of n, a(n) for n = 1..9592</a>

%e The last digit of 13 is not '0' and 31 is prime, therefore we append 31.

%t a = Select[Range[196], IntegerDigits[ # ][[ -1]] != 0 && PrimeQ[FromDigits[Reverse[ IntegerDigits[ # ]]]] &]; b = {}; For[n = 1, n < Length[a] + 1, n++, AppendTo[b, FromDigits[Reverse[IntegerDigits[a[[n]]]]]]]; b

%o (PARI) left(str, n) = { my(v, tmp, x); v =""; tmp = Vec(str); ln=length(tmp); if(n > ln, n=ln); for(x=1, n, v=concat(v, tmp[x]); ); return(v) } \\ Get the left n characters from string str

%o rev(str) = { local(tmp, s, j); tmp = Vec(Str(str)); s=""; forstep(j=length(tmp), 1, -1, s=concat(s, tmp[j])); return(s) } \\ Get the reverse of the input string

%o rprime(n) = { local(x, y, v); for(x=1, n, y=rev(x); v=Vec(y); if(left(y, 1)<> "0"&&isprime(eval(y)), print1(y", ")) ) }

%o (Python)

%o from itertools import count, islice

%o from sympy import primerange

%o def A104154_gen(): # generator of terms

%o yield from (int(d[::-1]) for l in count(1) for d in sorted(str(m)[::-1] for m in primerange(10**(l-1),10**l)))

%o A104154_list = list(islice(A104154_gen(),20)) # _Chai Wah Wu_, Feb 17 2022

%Y Cf. A004087.

%K nonn,base,look,easy

%O 1,1

%A _Cino Hilliard_, Mar 09 2005

%E Edited by _Stefan Steinerberger_, Aug 01 2007