close
login
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
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)>;
// Jason Kimberley, Feb 11 2013
CROSSREFS
Cf. A101211.
Sequence in context: A238268 A194883 A328404 * A014499 A055778 A348772
KEYWORD
base,nonn,easy
AUTHOR
Leroy Quet, May 16 2010
EXTENSIONS
Extended by Jason Kimberley, Feb 11 2013
STATUS
approved