login
A162404
a(1)=1. a(n) = a(n-1) + (the largest value among (a(1),a(2),...,a(n-1)) 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
OFFSET
1,2
LINKS
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[n-1]+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
Sequence in context: A289536 A022426 A005677 * A084760 A186082 A103746
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