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.

A232127 Maximal number of digits that can be appended to prime(n) preserving primality at each step.

This page as a plain text file.
%I A232127 #17 Jul 07 2021 09:28:45
%S A232127 7,7,7,7,1,6,3,8,6,6,3,6,1,5,3,0,6,5,5,4,6,1,1,0,2,4,9,0,4,0,5,1,1,5,
%T A232127 3,1,2,1,0,2,0,4,2,3,7,5,2,3,4,3,5,4,5,0,4,3,4,5,3,1,1,5,1,2,2,0,6,3,
%U A232127 0,4,5,2,4,5,1,2,0,0,3,10,0,3,0,2,4,0,3,0,0,6
%N A232127 Maximal number of digits that can be appended to prime(n) preserving primality at each step.
%C A232127 Consider chains (p^(0),p^(1),p^(2),...p^(L)) of primes such that p^(k-1) = floor(p^(k)/10), or otherwise said, p^(k+1) is obtained from p^(k) by appending a digit. Then a(n) is one less than the number of primes in the longest possible such chain with p^(0)=prime(n).
%H A232127 Michael S. Branicky, <a href="/A232127/b232127.txt">Table of n, a(n) for n = 1..10000</a>
%H A232127 Archimedes' Lab, <a href="http://www.archimedes-lab.org/numbers/Num24_69.html">What's Special About This Number?</a>, section about 43.
%F A232127 a(n)=A232128(A000040(n)).
%F A232127 a(n) > 0 if and only if there is a prime p between 10*prime(n)+1 and 10*prime(n)+9, in which case a(n) >= 1+a(primepi(p))
%F A232127 a(n) = max { L in N | exists (p[0],...,p[L]) in P^(L+1) (P = the primes A000040), such that p[0] = prime(n) and for k=1,...,L : p[k-1] = floor(p[k]/10) }
%e A232127 a(14)=5 because for prime(14)=43, one can add at most 5 digits to the right preserving primality at each step: 439 is prime, 4391 is prime, 43913 is prime, 439133 is prime, 4391339 is prime. There is no longer chain possible starting with 43.
%o A232127 (PARI) {howfar(p)=my(m);forstep(d=1,9,2,d==5&&next;isprime(p*10+d)||next;m=max(1+howfar(10*p+d),m));m}
%o A232127 (Python)
%o A232127 from sympy import isprime, prime
%o A232127 def a(n):
%o A232127   pn = prime(n); ftr = {pn}; ext = 0
%o A232127   while len(ftr) > 0:
%o A232127     r1 = set(filter(isprime, (int(str(e)+d) for d in "1379" for e in ftr)))
%o A232127     ext, ftr = ext+1, r1
%o A232127   return ext - 1
%o A232127 print([a(n) for n in range(1, 91)]) # _Michael S. Branicky_, Jul 07 2021
%o A232127 (Python) # faster version for initial segment of sequence
%o A232127 from sympy import isprime, prime, primerange
%o A232127 def aupton(terms):
%o A232127   alst = []
%o A232127   for p in primerange(1, prime(terms)+1):
%o A232127     r = {p}; e = 0
%o A232127     while len(r) > 0:
%o A232127       r1 = set(filter(isprime, (int(str(e)+d) for d in "1379" for e in r)))
%o A232127       e, r = e+1, r1
%o A232127     alst.append(e - 1)
%o A232127   return alst
%o A232127 print(aupton(90)) # _Michael S. Branicky_, Jul 07 2021
%Y A232127 Cf. A232125.
%K A232127 nonn,base
%O A232127 1,1
%A A232127 _M. F. Hasler_ and _Michel Marcus_, Nov 19 2013