

A162404


a(1)=1. a(n) = a(n1) + (the largest value among (a(1),a(2),...,a(n1)) that when written in binary occurs as a substring in the binary representation of n).


3



1, 2, 3, 5, 10, 13, 16, 18, 20, 30, 35, 38, 51, 54, 57, 73, 75, 93, 96, 116, 126, 131, 136, 139, 142, 155, 168, 171, 184, 214, 217, 233, 249, 251, 286, 304, 322, 360, 363, 383, 403, 413, 423, 428, 441, 446, 451, 467, 470, 488, 539, 559, 572, 626, 639, 642, 699
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

1,2


LINKS

Robert Israel, Table of n, a(n) for n = 1..10000


MAPLE

a[1]:= 1: sa[1]:= "1":
m:= 1:
for n from 2 to 1000 do
if n > a[m] and n > m+1 then m:= m+1 fi;
bn:= convert(convert(n, binary), string);
for j from m by 1 to 1 do
if StringTools[Search](sa[j], bn) <> 0 then
a[n]:= a[n1]+a[j];
sa[n]:= convert(convert(a[n], binary), string);
break
fi
od
od:
seq(a[n], n=1..1000); # Robert Israel, Oct 07 2015


MATHEMATICA

a[1] = 1; a[n_] := a[n] = a[n  1] + Max@ Select[ Table[ a@i, {i, 0, n  1}], StringPosition[ ToString@ FromDigits@ IntegerDigits[n, 2], ToString@ FromDigits@ IntegerDigits[ #, 2]] != {} &]; Table[ a@n, {n, 57}] (* Robert G. Wilson v, Aug 17 2009 *)


CROSSREFS

Cf. A162405, A162406.
Sequence in context: A289536 A022426 A005677 * A084760 A186082 A103746
Adjacent sequences: A162401 A162402 A162403 * A162405 A162406 A162407


KEYWORD

base,nonn


AUTHOR

Leroy Quet, Jul 02 2009


EXTENSIONS

a(13) to a(57) from Robert G. Wilson v, Aug 17 2009


STATUS

approved



