A220400 Number of ways to write n as sum of at least 2 consecutive odd positive integers.
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, 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, 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
Offset: 0
Keywords
Examples
For n=16 we can write 1+3+5+7 and 7+9, thus a(16) = 2. 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
Links
- Antti Karttunen, Table of n, a(n) for n = 0..11111
Programs
-
Mathematica
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 *)
-
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
-
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
Extensions
More terms from Antti Karttunen, Dec 27 2017
Comments