%I #32 Dec 28 2017 19:32:15
%S 0,0,0,0,1,0,0,0,1,1,0,0,1,0,0,1,2,0,0,0,1,1,0,0,2,1,0,1,1,0,0,0,2,1,
%T 0,1,2,0,0,1,2,0,0,0,1,2,0,0,3,1,0,1,1,0,0,1,2,1,0,0,2,0,0,2,3,1,0,0,
%U 1,1,0,0,3,0,0,2,1,1,0,0,3,2,0,0,2,1,0,1,2,0,0,1,1,1,0,1,4,0,0,2,2,0,0,0,2,3
%N Number of ways to write n as sum of at least 2 consecutive odd positive integers.
%C Records occur at 0, 4, 16, 48, 96, 144, 240, 480, 720, 960, 1440, ..., (A297160). - _Antti Karttunen_, Dec 27 2017
%C Also number of ways to express n in the form k + (k + 2) + ... + (k + 2*m - 2) = m * (k + m - 1) where k > 0 is odd and m > 0 and m * (m + 1) < n. - _David A. Corneth_, Dec 27 2017
%H Antti Karttunen, <a href="/A220400/b220400.txt">Table of n, a(n) for n = 0..11111</a>
%e For n=16 we can write 1+3+5+7 and 7+9, thus a(16) = 2.
%e For n = 24, we look for sums of consecutive numbers of m terms of the form m * (k + m - 1) for odd k and m * (m + 1) < 24, i.e., m < 5. We can factorize 24 as such in two positive factors as 1 * 24 = 2 * 12 = 3 * 8 = 4 * 6 giving m = 1, 2, 3 and 4 respectively. Solving for k gives k = 24, k = 11, k = 6 and k = 3 respectively. Of these values, two are odd so a(24) = 2. Superfluously, the corresponding sums are 11 + 13 = 3 + 5 + 7 + 9. - _David A. Corneth_, Dec 28 2017
%t nn = 100; t = Table[0, {nn}]; Do[s = odd = 2*n - 1; While[odd = odd + 2; s = s + odd; s <= nn, t[[s]]++], {n, nn/2}]; Join[{0}, t] (* _T. D. Noe_, Dec 18 2012 *)
%o (Scheme) (define (A220400 n) (let loop ((s 0) (begin 1) (end 1) (sum 1)) (cond ((> begin (/ n 2)) s) ((< sum n) (loop s begin (+ end 2) (+ sum end 2))) ((> sum n) (loop s (+ begin 2) end (- sum begin))) (else (loop (+ 1 s) (+ begin 2) end (- sum begin)))))) ;; _Antti Karttunen_, Dec 27 2017
%o (PARI) a(n) = if(n==0, return(0)); my(d = divisors(n)); (#d + 1) \ 2 - sum(i = 2, (#d + 1) \ 2, (n / d[i] - d[i]) % 2) - 1 \\ _David A. Corneth_, Dec 27 2017
%Y Cf. A069283 (even numbers lead to this sequence).
%Y Cf. A297160 (positions of records).
%K nonn
%O 0,17
%A _Carl Najafi_, Dec 13 2012
%E More terms from _Antti Karttunen_, Dec 27 2017
|