This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A239907 #47 Apr 27 2024 03:33:59 %S A239907 0,0,1,2,3,3,5,5,7,7,8,9,11,11,12,13,15,15,16,17,18,18,20,20,23,23,24, %T A239907 25,26,26,28,28,31,31,32,33,34,34,36,36,38,38,39,40,42,42,43,44,47,47, %U A239907 48,49,50,50,52,52,54,54,55,56,58,58,59,60,63,63,64,65,66,66,68,68,70,70,71,72,74,74,75 %N A239907 Let cn(n,k) denote the number of times 11..1 (k 1's) appears in the binary representation of n; a(n) = n - cn(n,1) + cn(n,2) - cn(n,3) + cn(n,4) - ... . %H A239907 Gheorghe Coserea, <a href="/A239907/b239907.txt">Table of n, a(n) for n = 0..10000</a> %H A239907 Jon Maiga, <a href="http://sequencedb.net/s/A239907">Computer-generated formulas for A239907</a>, Sequence Machine. %F A239907 Conjecture: a(n) = n - A329320(n) for n >= 0 (noticed by Sequence Machine). - _Mikhail Kurkov_, Oct 13 2021 %p A239907 # From A014081: %p A239907 cn := proc(v, k) local n, s, nn, i, j, som, kk; %p A239907 som := 0; %p A239907 kk := convert(cat(seq(1, j = 1 .. k)), string); %p A239907 n := convert(v, binary); %p A239907 s := convert(n, string); %p A239907 nn := length(s); %p A239907 for i to nn - k + 1 do %p A239907 if substring(s, i .. i + k - 1) = kk then som := som + 1 fi od; %p A239907 som; end; %p A239907 g:=n->add((-1)^i*cn(n,i),i=1..10); # assumes n < 1023 %p A239907 [seq(n+g(n), n=0..100)]; %t A239907 cn[n_, k_] := Count[Partition[IntegerDigits[n, 2], k, 1], Table[1, {k}]]; Table[n - Sum[cn[n, i], {i, 1, IntegerLength[n, 2], 2}] + Sum[cn[n, i], {i, 2, IntegerLength[n, 2], 2}], {n, 0, 78}] (* _Michael De Vlieger_, Sep 18 2015 *) %o A239907 (PARI) %o A239907 binruns(n) = { %o A239907 if (n == 0, return([1, 0])); %o A239907 my(bag = List(), v=0); %o A239907 while(n != 0, %o A239907 v = valuation(n,2); listput(bag, v); n >>= v; n++; %o A239907 v = valuation(n,2); listput(bag, v); n >>= v; n--); %o A239907 return(Vec(bag)); %o A239907 }; %o A239907 a(n) = { %o A239907 my(v = binruns(n)); %o A239907 n - sum(i = 1, #v, if (i%2 == 0, (v[i] + 1)\2, 0)) %o A239907 }; %o A239907 vector(79, i, a(i-1)) \\ _Gheorghe Coserea_, Sep 18 2015 %Y A239907 Cf. A000120, A012081, A014082, A239904, A239906. %K A239907 nonn,base %O A239907 0,4 %A A239907 _N. J. A. Sloane_, Apr 07 2014