|
|
A175453
|
|
a(1)=1. a(n) = sum a(k), where k, taken over the runs (of both 0's and 1's) in binary n, equals the length of each run.
|
|
1
|
|
|
1, 2, 2, 3, 3, 3, 2, 3, 4, 4, 4, 4, 4, 3, 3, 4, 4, 5, 5, 5, 5, 5, 4, 4, 5, 5, 5, 4, 4, 4, 3, 4, 5, 5, 5, 6, 6, 6, 5, 5, 6, 6, 6, 6, 6, 5, 5, 5, 5, 6, 6, 6, 6, 6, 5, 4, 5, 5, 5, 5, 5, 4, 3, 4, 5, 6, 6, 6, 6, 6, 5, 6, 7, 7, 7, 7, 7, 6, 6, 6, 6, 7, 7, 7, 7, 7, 6, 6, 7, 7, 7, 6, 6, 6, 5, 5, 6, 6, 6, 7, 7, 7, 6, 6
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,2
|
|
LINKS
|
|
|
EXAMPLE
|
23 in binary is 10111. There is a run of one 1, followed by a run of one 0, followed finally by a run of three 1's. So, a(23) = a(1)+a(1)+a(3) = 1+1+2 = 4.
|
|
PROG
|
(Magma)
runs := function(s)
r := []; c := 1;
for i in [1..#s-1] do
if s[i] eq s[i+1]
then c +:= 1;
else Append(~r, c); c := 1;
end if;
end for;
Append(~r, c);
return r;
end function;
A175453 := func<n|n eq 1 select 1 else
&+[$$(k):k in runs(b)]where b is IntegerToSequence(n, 2)>;
|
|
CROSSREFS
|
|
|
KEYWORD
|
base,nonn,easy
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|