login
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

%I #15 Sep 08 2022 08:45:51

%S 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,

%T 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,

%U 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

%N 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.

%H Jason Kimberley, <a href="/A175453/b175453.txt">Table of n, a(n) for n = 1..5000</a>

%e 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.

%o (Magma)

%o runs := function(s)

%o r := []; c := 1;

%o for i in [1..#s-1] do

%o if s[i] eq s[i+1]

%o then c +:= 1;

%o else Append(~r,c); c := 1;

%o end if;

%o end for;

%o Append(~r,c);

%o return r;

%o end function;

%o A175453 := func<n|n eq 1 select 1 else

%o &+[$$(k):k in runs(b)]where b is IntegerToSequence(n,2)>;

%o // _Jason Kimberley_, Feb 11 2013

%Y Cf. A101211.

%K base,nonn,easy

%O 1,2

%A _Leroy Quet_, May 16 2010

%E Extended by _Jason Kimberley_, Feb 11 2013