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.

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

This page as a plain text file.
%I A380227 #10 Jan 24 2025 16:50:41
%S A380227 11,3,11,31,59,463,131,103,599,3253,7649,439,12791,2953,17321,16651,
%T A380227 10007,51787,4871,1483,6857,15649,53051,61441,84449,35533,19913,39097,
%U A380227 23081,206527,44939,189517,32369,106657,606899,117703,222977,220903,69779,12007,95063,136471,43973
%N A380227 Beginning with 11, least prime such that concatenation of first n terms and its digit reversal both are primes.
%p A380227 rev:= proc(n) local L,i;
%p A380227   L:= convert(n,base,10);
%p A380227   add(L[-i]*10^(i-1),i=1..nops(L))
%p A380227 end proc:
%p A380227 tcat:= proc(a,b)
%p A380227   a*10^(1+ilog10(b))+b
%p A380227 end proc:
%p A380227 A:= 11: x:= 11:
%p A380227 for i from 1 to 50 do
%p A380227    p:= 2:
%p A380227    do
%p A380227      p:= nextprime(p);
%p A380227      y:= tcat(x,p);
%p A380227      if isprime(y) and isprime(rev(y)) then
%p A380227           A:= A,p;
%p A380227           x:= y;
%p A380227           break
%p A380227      fi;
%p A380227    od
%p A380227 od:
%p A380227 A; # after _Robert Israel_ in A113584
%t A380227 w={11};Do[k=1;q=Monitor[Parallelize[While[True,If[PrimeQ[FromDigits[Join@@IntegerDigits/@Reverse[IntegerDigits[FromDigits[Join@@IntegerDigits/@Append[w,Prime[k]]]]]]]&&PrimeQ[FromDigits[Join@@IntegerDigits/@Append[w,Prime[k]]]],Break[]];k++];Prime[k]],{i,k}];w=Append[w,q],{i,2,50}];w
%o A380227 (Python)
%o A380227 from itertools import count, islice
%o A380227 from gmpy2 import digits, is_prime, mpz, next_prime
%o A380227 def agen(): # generator of terms
%o A380227     s, r, an = "", "", 11
%o A380227     while True:
%o A380227         yield int(an)
%o A380227         d = digits(an)
%o A380227         s, r, p, sp = s+d, d[::-1]+r, 3, "3"
%o A380227         while not is_prime(mpz(s+sp)) or not is_prime(mpz(sp[::-1]+r)):
%o A380227             p = next_prime(p)
%o A380227             sp = digits(p)
%o A380227         an = p
%o A380227 print(list(islice(agen(), 40))) # after _Michael S. Branicky_ in A113584
%Y A380227 Cf. A113584 (same for 3), A379761 (same for 7).
%Y A380227 Cf. A111382, A111383, A379354, A379355.
%K A380227 base,nonn
%O A380227 1,1
%A A380227 _J.W.L. (Jan) Eerland_, Jan 17 2025