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.

A101115 Beginning with the n-th prime, the number of successive times a new prime can be formed by prepending the smallest nonzero digit.

This page as a plain text file.
%I A101115 #18 Jun 24 2022 17:21:07
%S A101115 0,5,0,9,5,4,8,4,5,9,4,6,2,7,6,8,9,7,6,3,14,5,5,2,4,10,1,5,7,3,4,3,5,
%T A101115 5,0,6,5,8,5,13,4,5,4,5,3,8,4,4,5,8,3,6,1,4,4,2,5,2,2,3,4,9,8,7,4,7,3,
%U A101115 3,5,5,7,8,4,3,3,2,1,7,0,4,3,5,3,7,9,6,6,5,6,8
%N A101115 Beginning with the n-th prime, the number of successive times a new prime can be formed by prepending the smallest nonzero digit.
%C A101115 It is possible the procedure described would generate some left-truncatable primes (A024785). Although zero digits cannot be added, it is possible the starting prime may contain zeros. Therefore the possible number of digit additions is not limited by the length of the largest known left-truncatable prime. Further, because the smallest digit that satisfies the requirement is used each time, it is possible that choosing a larger digit would allow more single digits to be added. Therefore although some of the set of left-truncatable primes may be generated by this practice, not all of them will.
%C A101115 In principle it is possible that some a(n) is undefined because the process could go on indefinitely, but this is very unlikely.  The largest a(n) for n <= 300000 is a(49120) = 18. - _Robert Israel_, Jun 29 2015
%H A101115 Robert Israel, <a href="/A101115/b101115.txt">Table of n, a(n) for n = 1..10000</a>
%H A101115 I. O. Angell, and H. J. Godwin, <a href="http://dx.doi.org/10.1090/S0025-5718-1977-0427213-2">On Truncatable Primes</a>, Math. Comput. 31, 265-267, 1977.
%H A101115 <a href="/index/Tri#tprime">Index entries for sequences related to truncatable primes</a>
%e A101115 a(2) is 5 because the second prime is 3, to which single nonzero digits can be prepended 5 times yielding a new prime each time (giving preference to the smallest digit that satisfies the requirement): 13, 113, 2113, 12113, 612113 (see A053583). There is no nonzero digit which can be prepended to 612113 to yield a new prime.
%e A101115 a(21) = 14 because the 21st prime (73) can be prepended with single nonzero digits 14 times yielding a new prime each time: 73, 173, 6173, 66173, ..., 4818372912366173.
%p A101115 f:= proc(n) local p, nd, d, count, x, success;
%p A101115       p:= ithprime(n); nd:= ilog10(p);
%p A101115       for count from 0 do
%p A101115         nd:= nd+1;
%p A101115         success:= false;
%p A101115         for d from 1 to 9 do
%p A101115           x:= 10^nd * d + p;
%p A101115           if isprime(x) then
%p A101115              success:= true;
%p A101115              break
%p A101115           fi
%p A101115         od;
%p A101115         if not success then return(count) fi;
%p A101115         p:= x;
%p A101115       od
%p A101115 end proc:
%p A101115 map(f, [$1..100]); # _Robert Israel_, Jun 29 2015
%o A101115 (Python)
%o A101115 from sympy import isprime, prime
%o A101115 def a(n):
%o A101115     pn = prime(n)
%o A101115     s, c, found = str(pn), 0, True
%o A101115     while found:
%o A101115         found = False
%o A101115         for d in "123456789":
%o A101115             if isprime(int(d+s)):
%o A101115                 s, c, found = d+s, c+1, True
%o A101115                 break
%o A101115     return c
%o A101115 print([a(n) for n in range(1, 91)]) # _Michael S. Branicky_, Jun 24 2022
%Y A101115 Cf. A053583, A024785, A000040, A101116, A101117, A101118.
%K A101115 base,nonn
%O A101115 1,2
%A A101115 Chuck Seggelin (seqfan(AT)plastereddragon.com), Dec 02 2004