login
Start with 9; thereafter, primes obtained by concatenating to the end of previous term the next smallest number that will produce a prime.
1

%I #24 Nov 23 2023 07:04:12

%S 9,97,971,9719,971917,97191713,9719171333,971917133323,9719171333237,

%T 971917133323777,97191713332377731,9719171333237773159,

%U 971917133323777315951,97191713332377731595127,971917133323777315951277,971917133323777315951277269

%N Start with 9; thereafter, primes obtained by concatenating to the end of previous term the next smallest number that will produce a prime.

%C a(n+1) is the next smallest prime beginning with a(n). Initial term is 9. After a(1), these are the primes in A069611.

%H Robert Israel, <a href="/A236672/b236672.txt">Table of n, a(n) for n = 1..316</a>

%e a(1) = 9 by definition.

%e a(2) is the next smallest prime beginning with 9, so a(2) = 97.

%e a(3) is the next smallest prime beginning with 97, so a(3) = 971.

%p R:= 9: x:= 9:

%p for i from 2 to 20 do

%p for y from 1 by 2 do

%p z:= x*10^(1+ilog10(y)) + y;

%p if isprime(z) then

%p R:= R,z; x:= z; break

%p fi

%p od od:

%p R; # _Robert Israel_, Nov 22 2023

%t next[p_]:=Module[{i=1,q},While[!PrimeQ[q=10^IntegerLength[i]p+i],i+=2];q];

%t NestList[next,9,15] (* _Paolo Xausa_, Nov 23 2023 *)

%o (Python)

%o import sympy

%o from sympy import isprime

%o def b(x):

%o num = str(x)

%o n = 1

%o while n < 10**3:

%o new_num = str(x) + str(n)

%o if isprime(int(new_num)):

%o print(int(new_num))

%o x = new_num

%o n = 1

%o else:

%o n += 1

%o b(9)

%Y Cf. A048553, A110773, A069611.

%K nonn,base

%O 1,1

%A _Derek Orr_, Jan 29 2014