login
a(1) = 1; thereafter a(n) = the smallest prime of the form d0...0a(n-1), where d is a single digit, or 0 if no such prime exists.
4

%I #22 Jun 23 2022 15:42:08

%S 1,11,211,4211,34211,234211,4234211,304234211,9304234211,209304234211,

%T 7209304234211,37209304234211,3037209304234211,23037209304234211,

%U 323037209304234211,70000323037209304234211,300070000323037209304234211,600300070000323037209304234211

%N a(1) = 1; thereafter a(n) = the smallest prime of the form d0...0a(n-1), where d is a single digit, or 0 if no such prime exists.

%C a(n) is the smallest prime obtained by prefixing a(n-1) with a number of the form d*10^k where d is a single digit, 0 < d < 10, and k >= 0. Conjecture: d*10^k always exists.

%H Alois P. Heinz, <a href="/A077714/b077714.txt">Table of n, a(n) for n = 1..52</a>

%e a(8) = 304234211; deleting 3 gives 4234211 = a(7).

%p a:= proc(n) option remember; local k, m, d, p;

%p if n=1 then 1 else k:= a(n-1);

%p for m from length(k) do

%p for d to 9 do p:= k +d*10^m;

%p if isprime(p) then return p fi

%p od od

%p fi

%p end:

%p seq(a(n), n=1..20); # _Alois P. Heinz_, Jan 12 2015

%o (Python)

%o from sympy import isprime

%o from itertools import islice

%o def agen(an=1):

%o while True:

%o yield an

%o pow10 = 10**len(str(an))

%o while True:

%o found = False

%o for t in range(pow10+an, 10*pow10+an, pow10):

%o if isprime(t):

%o an = t; found = True; break

%o if found: break

%o pow10 *= 10

%o print(list(islice(agen(), 18))) # _Michael S. Branicky_, Jun 23 2022

%Y Cf. A053582, A077713, A077715, A077716.

%K base,nonn

%O 1,2

%A _Amarnath Murthy_, Nov 19 2002

%E More terms from _Ray Chandler_, Jul 23 2003

%E Offset changed to 1 by _Alois P. Heinz_, Jan 12 2015

%E Definition clarified by _N. J. A. Sloane_, Jan 19 2015