login
Number of ways to write n as the sum of any number of consecutive integers (including the trivial one-term sum n = n).
12

%I #33 Nov 30 2020 08:45:31

%S 2,2,4,2,4,4,4,2,6,4,4,4,4,4,8,2,4,6,4,4,8,4,4,4,6,4,8,4,4,8,4,2,8,4,

%T 8,6,4,4,8,4,4,8,4,4,12,4,4,4,6,6,8,4,4,8,8,4,8,4,4,8,4,4,12,2,8,8,4,

%U 4,8,8,4,6,4,4,12,4,8,8,4,4,10,4,4,8,8,4,8,4,4,12,8,4,8,4,8,4,4,6,12,6

%N Number of ways to write n as the sum of any number of consecutive integers (including the trivial one-term sum n = n).

%C a(n) = twice the number of odd divisors of n. That is, if d is the divisor function and q is the exponent of the largest power of 2 dividing n, then the a(n) equals 2*d(n)/(q+1). - _Andrew Niedermaier_, Jul 20 2003

%C Moebius transform is period 2 sequence [2, 0, ...]. - _Michael Somos_, Sep 20 2005

%C a(n) is twice the number of partitions of n into consecutive parts. - _Omar E. Pol_, Nov 28 2020

%H Antti Karttunen, <a href="/A054844/b054844.txt">Table of n, a(n) for n = 1..65537</a>

%F a(n) = 2*A001227(n). - _Andrew Niedermaier_, Jul 20 2003

%F G.f.: Sum_{k>0} 2x^k/(1-x^(2k)) = Sum_{k>0} 2x^(2k-1)/(1-x^(2k-1)). - _Michael Somos_, Sep 20 2005

%F a(n) = A010054(n) + A335616(n). - _Omar E. Pol_, Nov 28 2020

%e a(3) = 4 because 3 = (-2)+(-1)+0+1+2+3 or 0+1+2 or 1+2 or 3; a(13) = 4 because 13 = (-12)+...+13 or (-5)+...+7 or 6+7 or 13.

%e From _Omar E. Pol_, Nov 28 2020: (Start)

%e Illustration of initial terms:

%e Diagram

%e n a(n) _ _

%e 1 2 _|1 1|_

%e 2 2 _|1 _ _ 1|_

%e 3 4 _|1 |1 1| 1|_

%e 4 2 _|1 _| |_ 1|_

%e 5 4 _|1 |1 _ _ 1| 1|_

%e 6 4 _|1 _| |1 1| |_ 1|_

%e 7 4 _|1 |1 | | 1| 1|_

%e 8 2 _|1 _| _| |_ |_ 1|_

%e 9 6 _|1 |1 |1 _ _ 1| 1| 1|_

%e 10 4 _|1 _| | |1 1| | |_ 1|_

%e 11 4 _|1 |1 _| | | |_ 1| 1|_

%e 12 4 _|1 _| |1 | | 1| |_ 1|_

%e 13 4 _|1 |1 | _| |_ | 1| 1|_

%e 14 4 _|1 _| _| |1 _ _ 1| |_ |_ 1|_

%e 15 8 _|1 |1 |1 | |1 1| | 1| 1| 1|_

%e 16 2 |1 | | | | | | | | 1|

%e ...

%e a(n) is the number of horizontal toothpicks in the n-th level of the diagram. (End)

%o (PARI) a(n)=2*sumdiv(n,d,d%2)

%o (PARI) A054844(n) = (2*numdiv(n>>valuation(n, 2))); \\ _Antti Karttunen_, Sep 27 2018

%Y Cf. A001227, A010054, A054843, A237593, A335616.

%K easy,nonn

%O 1,1

%A _Henry Bottomley_, Apr 13 2000

%E Corrected and extended by _Michael Somos_, Apr 26 2000