cp's OEIS Frontend

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.

A113584 Beginning with 3, least prime such that concatenation of first n terms and its digit reversal both are primes.

This page as a plain text file.
%I A113584 #22 Jan 02 2025 09:33:26
%S A113584 3,7,3,3,43,101,19,269,1873,41,241,3137,139,9011,9187,641,29881,12227,
%T A113584 3169,13499,8539,7019,19447,12899,73243,124769,1063,37847,127,32321,
%U A113584 104287,3407,93553,256643,165469,744659,60217,54773,49297,214457,314077,271409,602383,56921,193051,255383,75991,25667,583147,121019
%N A113584 Beginning with 3, least prime such that concatenation of first n terms and its digit reversal both are primes.
%H A113584 J.W.L. (Jan) Eerland, <a href="/A113584/b113584.txt">Table of n, a(n) for n = 1..224</a>
%p A113584 rev:= proc(n) local L,i;
%p A113584   L:= convert(n,base,10);
%p A113584   add(L[-i]*10^(i-1),i=1..nops(L))
%p A113584 end proc:
%p A113584 tcat:= proc(a,b)
%p A113584   a*10^(1+ilog10(b))+b
%p A113584 end proc:
%p A113584 A:= 3: x:= 3:
%p A113584 for i from 1 to 50 do
%p A113584    p:= 2:
%p A113584    do
%p A113584      p:= nextprime(p);
%p A113584      y:= tcat(x,p);
%p A113584      if isprime(y) and isprime(rev(y)) then
%p A113584           A:= A,p;
%p A113584           x:= y;
%p A113584           break
%p A113584      fi;
%p A113584    od
%p A113584 od:
%p A113584 A; # _Robert Israel_, Dec 26 2024
%t A113584 w = {3};
%t A113584 Do[k = 1;
%t A113584   q = Monitor[
%t A113584     Parallelize[
%t A113584      While[True,
%t A113584       If[PrimeQ[
%t A113584          FromDigits[
%t A113584           Join @@ IntegerDigits /@
%t A113584             Reverse[
%t A113584              IntegerDigits[
%t A113584               FromDigits[
%t A113584                Join @@ IntegerDigits /@ Append[w, Prime[k]]]]]]] &&
%t A113584         PrimeQ[FromDigits[
%t A113584           Join @@ IntegerDigits /@ Append[w, Prime[k]]]], Break[]]; k++];
%t A113584      Prime[k]], k];
%t A113584   w = Append[w, q], {i, 2, 50}];
%t A113584 w (* _J.W.L. (Jan) Eerland_, Dec 19 2024 *)
%o A113584 (Python)
%o A113584 from itertools import count, islice
%o A113584 from gmpy2 import digits, is_prime, mpz, next_prime
%o A113584 def agen(): # generator of terms
%o A113584     s, r, an = "", "", 3
%o A113584     while True:
%o A113584         yield int(an)
%o A113584         d = digits(an)
%o A113584         s, r, p, sp = s+d, d[::-1]+r, 3, "3"
%o A113584         while not is_prime(mpz(s+sp)) or not is_prime(mpz(sp[::-1]+r)):
%o A113584             p = next_prime(p)
%o A113584             sp = digits(p)
%o A113584         an = p
%o A113584 print(list(islice(agen(), 50))) # _Michael S. Branicky_, Jan 02 2025
%Y A113584 Cf. A111382, A111383.
%K A113584 base,nonn
%O A113584 1,1
%A A113584 _Amarnath Murthy_, Nov 06 2005
%E A113584 Corrected and extended by _Hans Havermann_, Nov 08 2005
%E A113584 a(40)-a(50) from _J.W.L. (Jan) Eerland_, Dec 19 2024