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.

Showing 1-5 of 5 results.

A158092 Number of solutions to +- 1 +- 2^2 +- 3^2 +- 4^2 +- ... +- n^2 = 0.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 2, 10, 0, 0, 86, 114, 0, 0, 478, 860, 0, 0, 5808, 10838, 0, 0, 55626, 100426, 0, 0, 696164, 1298600, 0, 0, 7826992, 14574366, 0, 0, 100061106, 187392994, 0, 0, 1223587084, 2322159814, 0, 0, 16019866270, 30353305134, 0, 0
Offset: 1

Views

Author

Pietro Majer, Mar 12 2009

Keywords

Comments

Twice A083527.
Number of partitions of the half of the n-th-square-pyramidal number into parts that are distinct square numbers in the range 1 to n^2. Example: a(7)=2 since, squarePyramidal(7)=140 and 70=1+4+16+49=9+25+36. - Hieronymus Fischer, Oct 20 2010
Erdős & Surányi prove that this sequence is unbounded. More generally, there are infinitely many ways to write a given number k as such a sum. - Charles R Greathouse IV, Nov 05 2012
The expansion and integral representation formulas below are due to Andrica & Tomescu. The asymptotic formula is a conjecture; see Andrica & Ionascu. - Jonathan Sondow, Nov 11 2013

Examples

			For n=8 the a(8)=2 solutions are: +1-4-9+16-25+36+49-64=0 and -1+4+9-16+25-36-49+64=0.
		

Crossrefs

Programs

  • Maple
    From Pietro Majer, Mar 15 2009: (Start)
    N:=60: p:=1: a:=[]: for n from 1 to N do p:=expand(p*(x^(n^2)+x^(-n^2))):
    a:=[op(a), coeff(p, x, 0)]: od:a; (End)
    # second Maple program:
    b:= proc(n, i) option remember; local m; m:= (1+(3+2*i)*i)*i/6;
          `if`(n>m, 0, `if`(n=m, 1, b(abs(n-i^2), i-1) +b(n+i^2, i-1)))
        end:
    a:= n-> `if`(irem(n-1, 4)<2, 0, 2*b(n^2, n-1)):
    seq(a(n), n=1..60);  # Alois P. Heinz, Nov 05 2012
  • Mathematica
    b[n_, i_] := b[n, i] = With[{m = (1+(3+2*i)*i)*i/6}, If[n>m, 0, If[n == m, 1, b[ Abs[n-i^2], i-1] + b[n+i^2, i-1]]]]; a[n_] := If[Mod[n-1, 4]<2, 0, 2*b[n^2, n-1]]; Table[a[n], {n, 1, 60}] (* Jean-François Alcover, Mar 13 2015, after Alois P. Heinz *)
  • PARI
    a(n)=2*sum(i=0,2^(n-1)-1,sum(j=1,n-1,(-1)^bittest(i,j-1)*j^2)==n^2) \\ Charles R Greathouse IV, Nov 05 2012
    
  • Python
    from itertools import count, islice
    from collections import Counter
    def A158092_gen(): # generator of terms
        ccount = Counter({0:1})
        for i in count(1):
            bcount = Counter()
            for a in ccount:
                bcount[a+(j:=i**2)] += ccount[a]
                bcount[a-j] += ccount[a]
            ccount = bcount
            yield(ccount[0])
    A158092_list = list(islice(A158092_gen(),20)) # Chai Wah Wu, Jan 29 2024

Formula

Constant term in the expansion of (x + 1/x)(x^4 + 1/x^4)..(x^n^2 + 1/x^n^2).
a(n)=0 for any n == 1 or 2 (mod 4).
Integral representation: a(n)=((2^n)/pi)*int_0^pi prod_{k=1}^n cos(x*k^2) dx
Asymptotic formula: a(n) = (2^n)*sqrt(10/(pi*n^5))*(1+o(1)) as n-->infty; n == -1 or 0 (mod 4).
a(n) = 2 * A083527(n). - T. D. Noe, Mar 12 2009
min{n : a(n) > 0} = A231015(0) = 7. - Jonathan Sondow, Nov 06 2013

Extensions

a(51)-a(56) from R. H. Hardin, Mar 12 2009
Edited by N. J. A. Sloane, Sep 15 2009

A231071 Number of solutions to n = +- 1^2 +- 2^2 +- 3^2 +- 4^2 +- ... +- k^2 for minimal k giving at least one solution.

Original entry on oeis.org

2, 1, 1, 1, 1, 1, 1, 1, 3, 2, 1, 1, 1, 1, 1, 1, 3, 1, 2, 1, 1, 1, 1, 1, 1, 6, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 3, 2, 2, 2, 1, 1, 2, 1, 2, 1, 2, 1, 9, 1, 3, 1, 1, 1, 2, 1, 1, 6, 1, 1, 1, 1, 1, 2, 1, 5, 1, 1, 1, 1, 4, 3, 1, 2, 1, 2, 2, 1, 2, 1, 14, 2, 1, 3, 2, 1, 2, 1, 1, 7, 1, 3, 2, 5, 1, 2, 1
Offset: 0

Views

Author

Alois P. Heinz, Nov 03 2013

Keywords

Comments

This type of sequence was first studied by Andrica and Vacaretu. - Jonathan Sondow, Nov 06 2013

Examples

			a(8) = 3: 8 = -1-4-9-16+25-36+49 = -1-4+9+16-25-36+49 = -1+4+9-16+25+36-49.
a(9) = 2: 9 = -1-4+9+16+25-36 = 1+4+9-16-25+36.
a(10) = 1: 10 = -1+4-9+16.
		

Crossrefs

Cf. A083527, A158092 (extremal sums).

Programs

  • Maple
    b:= proc(n, i) option remember; (m->`if`(n>m, 0, `if`(n=m, 1,
          b(n+i^2, i-1) +b(abs(n-i^2), i-1))))((1+(3+2*i)*i)*i/6)
        end:
    a:= proc(n) local k; for k while b(n, k)=0 do od; b(n, k) end:
    seq(a(n), n=0..100);
  • Mathematica
    b[n_, i_] := b[n, i] = Function[m, If[n > m, 0, If[n == m, 1,
       b[n+i^2, i-1] + b[Abs[n-i^2], i-1]]]][(1+(3+2*i)*i)*i/6];
    a[n_] := Module[{k}, For[k = 1, b[n, k] == 0, k++]; b[n, k]];
    Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Sep 01 2022, after Alois P. Heinz *)

Formula

From Jonathan Sondow, Nov 03 2013: (Start)
a(n(n+1)(2n+1)/6) = 1 for n > 0: n(n+1)(2n+1)/6 = 1+4+9+...+n^2. See A000330.
a(n(n+1)(2n+1)/6 - 2) = 1 for n > 1: n(n+1)(2n+1)/6 - 2 = -1+4+9+...+n^2. (End)

A231272 Numbers m with unique solution to m = +-1^2+-2^2+-3^2+-4^2+-...+-k^2 with minimal k giving at least one solution.

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 17, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 35, 36, 37, 38, 44, 45, 47, 49, 51, 53, 55, 56, 57, 59, 60, 62, 63, 64, 65, 66, 68, 70, 71, 72, 73, 76, 78, 81, 83, 86, 89, 91, 92, 94, 98, 100, 102, 106, 108, 109, 112
Offset: 1

Views

Author

Alois P. Heinz, Nov 06 2013

Keywords

Comments

Numbers m such that A231071(m) = 1. The value of k is given by A231015(m).

Examples

			10 is member of the sequence with unique minimal solution 10 = -1+4-9+16.
A000330(k) = k(k+1)(2k+1)/6 = 1^2 + 2^2 + ... + k^2 is a member for k > 0. - _Jonathan Sondow_, Nov 06 2013
		

Crossrefs

Cf. A000330, A231015, A231071, A231016 (complement).

Programs

  • Maple
    b:= proc(n, i) option remember; local m, t; m:= (1+(3+2*i)*i)*i/6;
          if n>m then 0 elif n=m then 1 else
             t:= b(abs(n-i^2), i-1);
             if t>1 then return 2 fi;
             t:= t+b(n+i^2, i-1); `if`(t>1, 2, t)
          fi
        end:
    a:= proc(n) option remember; local m, k;
          for m from 1+ `if`(n=1, -1, a(n-1)) do
            for k while b(m, k)=0 do od;
            if b(m, k)=1 then return m fi
          od
        end:
    seq(a(n), n=1..80);
  • Mathematica
    b[n_, i_] := b[n, i] = Module[{m, t}, m = (1 + (3 + 2*i)*i)*i/6; If[n > m,  0, If[n == m, 1, t = b[Abs[n - i^2], i - 1]; If[t > 1, Return[2]]; t = t + b[n + i^2, i - 1]; If[t > 1, 2, t]]]];
    a[n_] := a[n] = Module[{m, k}, For[m = 1 + If[n == 1, -1, a[n - 1]], True, m++, For[k = 1, b[m, k] == 0, k++]; If[b[m, k] == 1, Return[m]]]];
    Table[a[n], {n, 1, 80}] (* Jean-François Alcover, Sep 01 2022, after Alois P. Heinz *)

A140358 Smallest nonnegative integer k such that n = +-1+-2+-...+-k for some choice of +'s and -'s.

Original entry on oeis.org

0, 1, 3, 2, 3, 5, 3, 5, 4, 5, 4, 5, 7, 5, 7, 5, 7, 6, 7, 6, 7, 6, 7, 9, 7, 9, 7, 9, 7, 9, 8, 9, 8, 9, 8, 9, 8, 9, 11, 9, 11, 9, 11, 9, 11, 9, 11, 10, 11, 10, 11, 10, 11, 10, 11, 10, 11, 13, 11, 13, 11, 13, 11, 13, 11, 13, 11, 13, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 15, 13, 15, 13
Offset: 0

Views

Author

John W. Layman, Jun 23 2008

Keywords

Examples

			From _Seiichi Manyama_, Aug 18 2020: (Start)
Illustration of initial terms:
   0 =  0 (empty sum).
   1 =  1.
   2 =  1 - 2 + 3.
   3 =  1 + 2.
   4 = -1 + 2 + 3.
   5 =  1 + 2 + 3 + 4 - 5.
   6 =  1 + 2 + 3.
   7 =  1 + 2 + 3 - 4 + 5.
   8 = -1 + 2 + 3 + 4.
   9 =  1 + 2 - 3 + 4 + 5.
  10 =  1 + 2 + 3 + 4.
... (End)
		

Crossrefs

Programs

  • Maple
    b:= proc(n,i) option remember;
          (n=0 and i=0) or n<=i*(i+1)/2 and (b(abs(n-i), i-1) or b(n+i, i-1))
        end:
    a:= proc(n) local k;
          for k from 0 while not b(n,k) do od; k
        end:
    seq(a(n), n=0..100);  # Alois P. Heinz, Oct 19 2011
  • Mathematica
    b[n_, i_] := b[n, i] = (n==0 && i==0) || Abs[n] <= i(i+1)/2 && (b[n-i, i-1] || b[n+i, i-1]);
    a[n_] := Module[{k}, For[k = 0, !b[n, k], k++]; k];
    a /@ Range[0, 100] (* Jean-François Alcover, Nov 15 2020, after Alois P. Heinz *)

Formula

Conjecture when n is greater than 0. Choose k so that t(k)<=n
a(n) = a(-n) for all n in Z. - Seiichi Manyama, Aug 18 2020
Let k be the least integer such that t(k) >= n. If t(k) and n have the same parity then a(n) = k. Otherwise a(n) is equal to the least odd integer greater than k. - Rishi Advani, Jan 24 2021

Extensions

a(0)=3 prepended by Seiichi Manyama, Aug 17 2020
Edited and a(0)=0 from Alois P. Heinz, Aug 18 2020

A231016 Numbers m with non-unique solution to m = +- 1^2 +- 2^2 +- ... +- k^2 with minimal k giving at least one solution.

Original entry on oeis.org

0, 8, 9, 16, 18, 25, 31, 32, 33, 34, 39, 40, 41, 42, 43, 46, 48, 50, 52, 54, 58, 61, 67, 69, 74, 75, 77, 79, 80, 82, 84, 85, 87, 88, 90, 93, 95, 96, 97, 99, 101, 103, 104, 105, 107, 110, 111, 113, 115, 116, 117, 118, 121, 123, 127, 129, 131, 133, 135, 137, 141
Offset: 1

Author

Jonathan Sondow, Nov 06 2013

Keywords

Comments

The minimal k = A231015(m).
Complement of A231272.

Examples

			0 = 1 + 4 - 9 + 16 - 25 - 36 + 49 = sum with signs reversed, so 0 is a member.
9 = - 1 - 4 + 9 + 16 + 25 - 36 = 1 + 4 + 9 - 16 - 25 + 36, so 9 is a member.
A000330(k) = k(k+1)(2k+1)/6 = 1^2 + 2^2 + ... + k^2 is not a member, for k > 0.
		

Crossrefs

Programs

  • Maple
    b:= proc(n, i) option remember; local m, t; m:= (1+(3+2*i)*i)*i/6;
          if n>m then 0 elif n=m then 1 else
             t:= b(abs(n-i^2), i-1);
             if t>1 then return 2 fi;
             t:= t+b(n+i^2, i-1); `if`(t>1, 2, t)
          fi
        end:
    a:= proc(n) option remember; local m, k;
          for m from 1+ `if`(n=1, -1, a(n-1)) do
            for k while b(m, k)=0 do od;
            if b(m, k)>1 then return m fi
          od
        end:
    seq(a(n), n=1..80);  # Alois P. Heinz, Nov 06 2013
  • Mathematica
    b[n_, i_] := b[n, i] = Module[{m, t}, m = (1+(3+2*i)*i)*i/6; Which[n>m, 0, n == m, 1, True, t = b[Abs[n-i^2], i-1]; If[t>1, Return[2]]; t = t + b[n+i^2, i-1]; If[t>1, 2, t]]]; a[n_] := a[n] = Module[{m, k}, For[m = 1 + If[n == 1, -1, a[n-1]], True, m++, For[k = 1, b[m, k] == 0, k++]; If[b[m, k]>1, Return[m]]]]; Table[a[n], {n, 1, 80}] (* Jean-François Alcover, Jan 28 2014, after Alois P. Heinz *)

Formula

{ n : A231071(n) > 1 }.
Showing 1-5 of 5 results.