login
a(n) = Sum_{k = 1..n-1 such that n == k (mod 2^k)} 2^(k-1).
4

%I #38 Apr 26 2024 07:07:27

%S 0,0,1,0,1,2,1,0,1,2,5,0,1,2,1,0,1,2,5,8,1,2,1,0,1,2,5,0,1,2,1,0,1,2,

%T 5,8,17,2,1,0,1,2,5,0,1,2,1,0,1,2,5,8,1,2,1,0,1,2,5,0,1,2,1,0,1,2,5,8,

%U 17,34,1,0,1,2,5,0,1,2,1,0,1,2,5,8,1,2,1,0,1,2,5,0,1,2,1,0,1,2,5,8

%N a(n) = Sum_{k = 1..n-1 such that n == k (mod 2^k)} 2^(k-1).

%C Is there a simpler closed form?

%H Robert Israel, <a href="/A103528/b103528.txt">Table of n, a(n) for n = 1..10000</a>

%H David Applegate, Benoit Cloitre, Philippe Deléham and N. J. A. Sloane, Sloping binary numbers: a new sequence related to the binary numbers [<a href="http://neilsloane.com/doc/slopey.pdf">pdf</a>, <a href="http://neilsloane.com/doc/slopey.ps">ps</a>].

%H David Applegate, Benoit Cloitre, Philippe Deléham and N. J. A. Sloane, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL8/Sloane/sloane300.html">Sloping binary numbers: a new sequence related to the binary numbers</a>, J. Integer Seq. 8 (2005), no. 3, Article 05.3.6, 15 pp.

%F a(n) = (A102371(n) + n)/2 - 2^(n-1). - _Philippe Deléham_, Mar 27 2005

%F G.f.: Sum_{k>=1} 2^(k-1) x^(k+2^k)/(1 - x^(2^k)). - _Robert Israel_, Jan 21 2017

%F Conjecture: a(n) = (b(n) - b(n-1) - 1)/2 for n > 1 where b(n) = Sum_{k=0..A000523(n)} c(n-k, k) and c(n, m) = n - (n mod 2^m) with a(1) = 0. - _Mikhail Kurkov_, Jun 01 2022

%p f:=proc(n) local t1,k; t1:=0; for k from 1 to n-1 do if n mod 2^k = k then t1:=t1+2^(k-1); fi; od: t1; end;

%t (* b = A102371 (using _Alex Ratushnyak_'s code) *)

%t b[n_] := b[n] = If[n == 1, 1, BitXor[b[n-1], b[n-1] + n]];

%t a[n_] := (b[n] + n)/2 - 2^(n-1);

%t Array[a, 100] (* _Jean-François Alcover_, Apr 11 2019, after _Philippe Deléham_ *)

%o (PARI) a(n) = sum(k = 1, n-1, if ((n % 2^k) == k, 2^(k-1))); \\ _Michel Marcus_, May 06 2020

%Y Cf. A102371.

%K nonn,look

%O 1,6

%A _N. J. A. Sloane_, Mar 22 2005