login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A165414 a(n) = number of run-lengths that each occur only once in the binary representation of n. 2

%I #16 May 11 2017 11:41:33

%S 1,0,1,2,0,2,1,2,1,0,1,0,1,2,1,2,1,1,1,1,0,1,1,2,1,1,1,2,1,2,1,2,1,1,

%T 3,0,1,0,3,1,1,0,1,0,1,1,1,2,3,0,0,0,1,0,3,0,3,1,3,2,1,2,1,2,1,1,3,2,

%U 1,2,1,2,0,1,0,1,0,2,3,1,1,1,0,1,0,1,1,2,0,1,0,2,1,1,1,2,3,2,1,1,0,1,1,2,0

%N a(n) = number of run-lengths that each occur only once in the binary representation of n.

%H Gheorghe Coserea, <a href="/A165414/b165414.txt">Table of n, a(n) for n = 1..10000</a>

%e 92 in binary is 1011100. There is a run of one 1, followed by a run of one 0, then a run of three 1's, then finally a run of two 0's. The run lengths are therefore (1,1,3,2). The values of these run lengths that each only occur once are (3,2). Since there are 2 values that occur once, then a(92) = 2.

%t Table[Count[Tally[Length/@Split[IntegerDigits[n,2]]],_?(#[[2]]==1&)],{n,120}] (* _Harvey P. Dale_, May 11 2017 *)

%o (PARI)

%o binruns(n) = {

%o if (n == 0, return([1, 0]));

%o my(bag = List(), v=0);

%o while(n != 0,

%o v = valuation(n,2); listput(bag, v); n >>= v; n++;

%o v = valuation(n,2); listput(bag, v); n >>= v; n--);

%o return(Vec(bag));

%o };

%o a(n) = {

%o my(v = binruns(n), hist = vector(1+logint(n+1, 2)));

%o for (i = 1, #v, if (v[i] != 0, hist[v[i]]++));

%o #select(k->(k==1), hist)

%o };

%o vector(105, i, a(i)) \\ _Gheorghe Coserea_, Sep 24 2015

%Y Cf. A005811, A165413.

%K base,nonn

%O 1,4

%A _Leroy Quet_, Sep 17 2009

%E Extended by _Ray Chandler_, Mar 13 2010

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 2 07:06 EDT 2024. Contains 372178 sequences. (Running on oeis4.)