login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A088086 a(1) = 2; then smallest palindrome > 1 not occurring earlier such that every partial concatenation is a prime. 3

%I #16 Nov 18 2023 07:26:50

%S 2,3,9,11,313,33,9339,303,909,747,383,7,969,797,141,12721,1881,161,

%T 343,77,333,7227,181,737,30603,14841,12621,1111,15051,777,939,7887,

%U 7997,13231,191,79297,13331,11511,19191,38583,3993,949,17171,15351,318813

%N a(1) = 2; then smallest palindrome > 1 not occurring earlier such that every partial concatenation is a prime.

%H Robert Israel, <a href="/A088086/b088086.txt">Table of n, a(n) for n = 1..635</a>

%e 2, 23, 239, 23911, etc. are primes.

%p A:= [1,3,7,9]: B:= [1,3,7,9]:

%p P:= 3,7,9,op(zip((s,t) -> s*10+t, A, B)):

%p for d from 1 to 6 do

%p P:= P, op(zip(proc(s,t) local i; seq(10^(d+1)*s + 10^d*i + t,i=0..9) end proc, A, B)):

%p A:= map(proc(t) local i; seq(10*t+i,i=0..9) end proc, A);

%p B:= map(proc(t) local i; seq(10^d*i+t, i=0..9) end proc, B);

%p P:= P, op(zip((s,t) -> 10^(d+1)*s+t,A,B));

%p od:

%p P:= [P]:

%p R:= 2: p:= 2:

%p for i from 2 to 50 do

%p for j from 1 do

%p v:= p*10^(1+ilog10(P[j]))+P[j];

%p if isprime(v) then

%p p:= v;

%p R:= R, P[j];

%p P:= subsop(j=NULL, P);

%p break

%p fi

%p od od:

%p R; # _Robert Israel_, Nov 15 2023

%o (Python)

%o from gmpy2 import is_prime

%o from itertools import count, islice, product

%o def bgen(): # generator of palindromic decimal strings ending in 1, 3, 7, 9

%o yield from "379"

%o for digits in count(2):

%o for first in "1379":

%o for left in product("0123456789", repeat=(digits-2)//2):

%o left = "".join(left)

%o right = left[::-1]

%o for mid in [[""], "0123456789"][digits%2]:

%o yield first + left + mid + right + first

%o def agen():

%o alst, aset, concat = [2], {"2"}, "2"

%o while True:

%o yield alst[-1]

%o g = bgen()

%o s = next(g)

%o while "start" in s or s in aset or not is_prime(int(concat + s)):

%o s = next(g)

%o concat += s

%o aset.add(s)

%o alst.append(int(s))

%o print(list(islice(agen(), 45))) # _Michael S. Branicky_, Nov 18 2023

%Y Cf. A088087, A088084.

%K base,nonn

%O 1,1

%A _Amarnath Murthy_, Sep 22 2003

%E More terms from _Sam Alexander_, Nov 17 2003

%E More terms from _David Wasserman_, Jul 13 2005

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified September 17 15:22 EDT 2024. Contains 375987 sequences. (Running on oeis4.)