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.

A232128 Maximal number of digits that can be appended to n such that each step yields a prime.

This page as a plain text file.
%I A232128 #27 Sep 07 2021 09:28:05
%S A232128 9,7,7,6,7,6,7,2,3,10,1,6,6,4,3,2,3,5,8,0,3,5,6,6,5,5,6,2,6,2,3,0,7,5,
%T A232128 6,5,6,3,1,11,1,4,5,4,1,7,3,4,6,4,0,5,0,6,4,4,6,2,6,7,5,0,4,2,3,3,5,2,
%U A232128 5,4,4,1,6,2,4,4,1,7,1,4,4,10,1,0,5,1,6,5,0,1,4
%N A232128 Maximal number of digits that can be appended to n such that each step yields a prime.
%C A232128 The digits are to be appended one by one as to form a chain of L = a(n) primes [p^(1),...,p^(L)], such that p^(k-1)=floor(p^(k)/10), k=1,...,L, starting from the initial value p^(0) = n which is not required to be a prime. (See A232127 for the variant restricted to prime "starting values".)
%C A232128 See A232129 for the largest prime obtained when starting with n.
%H A232128 Robert Israel, <a href="/A232128/b232128.txt">Table of n, a(n) for n = 1..10000</a>
%F A232128 If a(n) > 0, then there is some prime p in the range 10n+1,...,10n+9 such that a(p)=a(n)-1. If a(n)=0, then there is no prime in that range.
%e A232128 a(1)=9 because "1" can be extended with at most 9 digits to the right such that each extension is prime; the least one of the possible 1+9 digit primes is 1979339333, the largest one is given in A232129.
%p A232128 f:= proc(n) local V,k;
%p A232128       V:= select(isprime, [seq(10*n+k, k=[1,3,7,9])]);
%p A232128       if V = [] then 0 else 1 + max(map(procname,V)) fi
%p A232128 end proc:
%p A232128 map(f, [$1..100]); # _Robert Israel_, Oct 16 2020
%o A232128 (PARI) a(n)=my(m,r=[0,n]);forstep(d=1,9,2,d==5&&next;isprime(n*10+d)||next;m=[1,0]+howfar(10*n+d);m[1]>r[1]&&r=m);r \\ Note: this returns the list [a(n), minimal longest prime]
%o A232128 (Python)
%o A232128 from sympy import isprime, nextprime
%o A232128 def a(n):
%o A232128     while True:
%o A232128         extends, reach, maxp = -1, {n}, 0
%o A232128         while len(reach) > 0:
%o A232128             candidates = (int(str(e)+d) for d in "1379" for e in reach)
%o A232128             reach1 = set(filter(isprime, candidates))
%o A232128             extends, reach, maxp = extends+1, reach1, max({maxp}|reach1)
%o A232128         return extends
%o A232128 print([a(n) for n in range(1, 92)]) # _Michael S. Branicky_, Sep 07 2021
%Y A232128 Cf. A232125, A232127, A232129.
%K A232128 nonn,base
%O A232128 1,1
%A A232128 _M. F. Hasler_, Nov 19 2013