cp's OEIS Frontend

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.

A220400 Number of ways to write n as sum of at least 2 consecutive odd positive integers.

Original entry on oeis.org

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

Views

Author

Carl Najafi, Dec 13 2012

Keywords

Comments

Records occur at 0, 4, 16, 48, 96, 144, 240, 480, 720, 960, 1440, ..., (A297160). - Antti Karttunen, Dec 27 2017
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

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
		

Crossrefs

Cf. A069283 (even numbers lead to this sequence).
Cf. A297160 (positions of records).

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