This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A111382 #16 Jan 03 2025 09:32:33 %S A111382 3,1,1,21,11,43,47,157,753,51,917,273,2409,703,413,3729,1153,6243, %T A111382 8789,2307,4477,137,403,10649,4617,4533,6133,4721,877,2469,5967,1557, %U A111382 1047,38931,15533,6877,23987,4767,18049,1463,118333,27897 %N A111382 Beginning with 3, least number such that concatenation of first n terms and its digit reversal both are primes. %H A111382 Robert Israel, <a href="/A111382/b111382.txt">Table of n, a(n) for n = 1..160</a> %p A111382 rev:= proc(n) local L,i; %p A111382 L:= convert(n,base,10); %p A111382 add(L[-i]*10^(i-1),i=1..nops(L)) %p A111382 end proc; %p A111382 R:= 3: X:= 3: XR:= 3: %p A111382 for i from 2 to 50 do %p A111382 for x from 1 by 2 do %p A111382 d:= 1+ilog10(x); %p A111382 t:= X*10^(1+ilog10(x)) + x; %p A111382 if not isprime(t) then next fi; %p A111382 xr:= rev(x); %p A111382 tr:= XR+xr*10^(1+ilog10(XR)); %p A111382 if isprime(tr) then break fi; %p A111382 od; %p A111382 X:= t; XR:= tr; R:= R,x; %p A111382 od: %p A111382 R; # _Robert Israel_, Aug 09 2023 %o A111382 (Python) %o A111382 from itertools import count, islice %o A111382 from gmpy2 import digits, is_prime, mpz %o A111382 def agen(): # generator of terms %o A111382 s, r, an = "", "", 3 %o A111382 while True: %o A111382 yield int(an) %o A111382 d = digits(an) %o A111382 s, r, k, sk = s+d, d[::-1]+r, 1, "1" %o A111382 while not is_prime(mpz(s+sk)) or not is_prime(mpz(sk[::-1]+r)): %o A111382 k += 2 %o A111382 if k%10 == 5: k += 2 %o A111382 sk = digits(k) %o A111382 an = k %o A111382 print(list(islice(agen(), 42))) # _Michael S. Branicky_, Jan 02 2025 %Y A111382 Cf. A113584. %K A111382 nonn,base %O A111382 1,1 %A A111382 _Hans Havermann_, Nov 08 2005