A101115 Beginning with the n-th prime, the number of successive times a new prime can be formed by prepending the smallest nonzero digit.
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, 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, 3, 5, 5, 7, 8, 4, 3, 3, 2, 1, 7, 0, 4, 3, 5, 3, 7, 9, 6, 6, 5, 6, 8
Offset: 1
Examples
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. 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.
Links
- Robert Israel, Table of n, a(n) for n = 1..10000
- I. O. Angell, and H. J. Godwin, On Truncatable Primes, Math. Comput. 31, 265-267, 1977.
- Index entries for sequences related to truncatable primes
Programs
-
Maple
f:= proc(n) local p, nd, d, count, x, success; p:= ithprime(n); nd:= ilog10(p); for count from 0 do nd:= nd+1; success:= false; for d from 1 to 9 do x:= 10^nd * d + p; if isprime(x) then success:= true; break fi od; if not success then return(count) fi; p:= x; od end proc: map(f, [$1..100]); # Robert Israel, Jun 29 2015
-
Python
from sympy import isprime, prime def a(n): pn = prime(n) s, c, found = str(pn), 0, True while found: found = False for d in "123456789": if isprime(int(d+s)): s, c, found = d+s, c+1, True break return c print([a(n) for n in range(1, 91)]) # Michael S. Branicky, Jun 24 2022
Comments