login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A014081 a(n) = number of occurrences of '11' in binary expansion of n. 39

%I

%S 0,0,0,1,0,0,1,2,0,0,0,1,1,1,2,3,0,0,0,1,0,0,1,2,1,1,1,2,2,2,3,4,0,0,

%T 0,1,0,0,1,2,0,0,0,1,1,1,2,3,1,1,1,2,1,1,2,3,2,2,2,3,3,3,4,5,0,0,0,1,

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

%N a(n) = number of occurrences of '11' in binary expansion of n.

%C a(n) takes the value k for the first time at n = 2^(k+1)-1. Cf. A000225. - _Robert G. Wilson v_, Apr 02 2009

%C a(n) = A213629(n,3) for n > 2. - _Reinhard Zumkeller_, Jun 17 2012

%H Reinhard Zumkeller, <a href="/A014081/b014081.txt">Table of n, a(n) for n = 0..10000</a>

%H Helmut Prodinger, <a href="http://dx.doi.org/10.1137/0603004">Generalizing the sum of digits function</a>, SIAM J. Algebraic Discrete Methods 3 (1982), no. 1, 35--42. MR0644955 (83f:10009).. [See B_2(11,n) on p. 35. - _N. J. A. Sloane_, Apr 06 2014]

%H R. Stephan, <a href="/somedcgf.html">Some divide-and-conquer sequences ...</a>

%H R. Stephan, <a href="/A079944/a079944.ps">Table of generating functions</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/DigitBlock.html">Digit Block</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/Rudin-ShapiroSequence.html">Rudin-Shapiro Sequence</a>

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%F a(4n) = a(4n+1) = a(n), a(4n+2) = a(2n+1), a(4n+3) = a(2n+1) + 1. - _Ralf Stephan_, Aug 21 2003

%F G.f.: 1/(1-x) * Sum_{k>=0} t^3/((1+t)*(1+t^2)), where t = x^(2^k). - _Ralf Stephan_, Sep 10 2003

%F a(n) = A000120(n) - A069010(n). - _Ralf Stephan_, Sep 10 2003

%e The binary expansion of 15 is 1111, which contains three occurrences of 11, so a(15)=3.

%p # To count occurrences of 11..1 (k times) in binary expansion of v:

%p cn := proc(v, k) local n, s, nn, i, j, som, kk;

%p som := 0;

%p kk := convert(cat(seq(1, j = 1 .. k)),string);

%p n := convert(v, binary);

%p s := convert(n, string);

%p nn := length(s);

%p for i to nn - k + 1 do

%p if substring(s, i .. i + k - 1) = kk then som := som + 1 fi od;

%p som; end; # This program no longer worked. Corrected by _N. J. A. Sloane_, Apr 06 2014.

%p [seq(cn(n,2),n=0..300)];

%p # Alternative:

%p A014081 := proc(n) option remember;

%p if n mod 4 <= 1 then procname(floor(n/4))

%p elif n mod 4 = 2 then procname(n/2)

%p else 1 + procname((n-1)/2)

%p fi

%p end proc:

%p A014081(0):= 0:

%p map(A014081, [$0..1000]); # _Robert Israel_, Sep 04 2015

%t f[n_] := Count[ Partition[ IntegerDigits[n, 2], 2, 1], {1, 1}]; Table[ f@n, {n, 0, 104}] (* _Robert G. Wilson v_, Apr 02 2009 *)

%o (Haskell)

%o import Data.Bits ((.&.))

%o a014081 n = a000120 (n .&. div n 2) -- _Reinhard Zumkeller_, Jan 23 2012

%o (PARI) A014081(n)=sum(i=0,#binary(n)-2,bitand(n>>i,3)==3) \\ _M. F. Hasler_, Jun 06 2012

%o (PARI) a(n) = hammingweight(bitand(n, n>>1)) ;

%o vector(105, i, a(i-1)) \\ _Gheorghe Coserea_, Aug 30 2015

%o (Python)

%o def a(n): return sum([((n>>i)&3==3) for i in range(len(bin(n)[2:]) - 1)]) # _Indranil Ghosh_, Jun 03 2017

%Y Cf. A014082, A033264, A037800, A056973, A000225, A213629, A000120, A069010.

%Y First differences give A245194.

%Y A245195 gives 2^a(n).

%K nonn,easy

%O 0,8

%A _Simon Plouffe_

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 3 13:15 EST 2021. Contains 341762 sequences. (Running on oeis4.)