

A067854


a(n) = cardinality of the (ordered) list L_n defined inductively by: L_1 = {2}; if, reading from left to right, there is a member p of L_n such that prime(n+1) can be appended to the beginning or end of p so that their neighboring digits are equal, then append prime(n+1) to the beginning or end of p to obtain L_(n+1); otherwise, add prime(n+1) to the end of the list L_n to obtain L_(n+1).


2



1, 2, 3, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 10, 10, 10, 11, 12, 12, 12, 12, 12, 13, 14, 15, 15, 16, 17, 18, 18, 19, 20, 21, 22, 23, 23, 23, 24, 25, 26, 26, 27, 28, 29, 30, 31, 31, 31, 32, 33, 34, 34, 35, 35, 36, 37, 37, 37, 37, 37, 37, 37, 37, 37
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

1,2


LINKS

Eric M. Schmidt, Table of n, a(n) for n = 1..10000


EXAMPLE

L_n for 1,...,5 are: {2}, {2,3}, {2,3,5}, {2,3,5,7}, {2,3,5,7,11}, so that a(i) = i for i = 1,...,5. Prime(6) = 13 can be appended to the beginning of 3 (in L_5) so that their neighboring digits (i.e. 3s) are equal. Hence L_6 = {2,133,5,7,11} and a(6) = 5. Prime(7) = 17 can be appended to the beginning of 7 in L_6 so that their neighboring digits are equal; so L_7 = {2,133,5,177,11} and a(7) = 5. It would be interesting to have a closedform expression giving, at least asymptotically or statistically, the value of a(n).


PROG

(Sage)
def a_list(n) :
res = []
curlist = []
for m in range(1, n+1) :
d = nth_prime(m).digits()
ds = [d[1], d[0]]
matcheditem = false
for i in range(len(curlist)) :
if curlist[i][0] == ds[1] :
curlist[i][0] = ds[0]
matcheditem = true
break
if curlist[i][1] == ds[0] :
curlist[i][1] = ds[1]
matcheditem = true
break
if not matcheditem : curlist.append(ds)
res.append(len(curlist))
return res
# Eric M. Schmidt, Oct 20 2016


CROSSREFS

Cf. A062406.
Sequence in context: A246264 A102676 A087846 * A194214 A251416 A087829
Adjacent sequences: A067851 A067852 A067853 * A067855 A067856 A067857


KEYWORD

base,easy,nonn


AUTHOR

Joseph L. Pe, Feb 15 2002


EXTENSIONS

Extended and corrected by Eric M. Schmidt, Oct 20 2016


STATUS

approved



