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!)
A014082 Number of occurrences of '111' in binary expansion of n. 16

%I #49 Mar 05 2023 15:20:31

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

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

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

%N Number of occurrences of '111' in binary expansion of n.

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

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

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

%H Ralf 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 <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

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

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

%p See A014081.

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

%p if n::even then procname(n/2)

%p elif n mod 8 = 7 then 1 + procname((n-1)/2)

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

%p fi

%p end proc:

%p f(0):= 0:

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

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

%t a[0] = a[1] = 0; a[n_] := a[n] = If[EvenQ[n], a[n/2], a[(n - 1)/2] + Boole[Mod[(n - 1)/2, 4] == 3]]; Table[a[n], {n, 0, 104}] (* _Jean-François Alcover_, Oct 22 2012, after _Ralf Stephan_ *)

%t Table[SequenceCount[IntegerDigits[n,2],{1,1,1},Overlaps->True],{n,0,110}] (* _Harvey P. Dale_, Mar 05 2023 *)

%o (Haskell)

%o import Data.List (tails, isPrefixOf)

%o a014082 = sum . map (fromEnum . ([1,1,1] `isPrefixOf`)) .

%o tails . a030308_row

%o -- _Reinhard Zumkeller_, Jun 17 2012

%o (PARI) a(n) = hammingweight(bitand(n, bitand(n>>1, n>>2))); \\ _Gheorghe Coserea_, Aug 30 2015

%Y Cf. A014081, A033264, A056974, A056975, A056976, A056977, A056978, A056979, A056980, A213629, A239906, A239907.

%K nonn,easy,base

%O 0,16

%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 | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 23 19:56 EDT 2024. Contains 371916 sequences. (Running on oeis4.)