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-3 of 3 results.

A231015 Least k such that n = +- 1^2 +- 2^2 +- 3^2 +- 4^2 +- ... +- k^2 for some choice of +- signs.

Original entry on oeis.org

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

Views

Author

Jonathan Sondow, Nov 02 2013

Keywords

Comments

Erdős and Surányi proved that for each n there are infinitely many k satisfying the equation.
A158092(k) is the number of solutions to 0 = +-1^2 +- 2^2 +- ... +- k^2. The first nonzero value is A158092(7) = 2, so a(0) = 7.
a(n) is also defined for n < 0, and clearly a(-n) = a(n).
See A158092 and the Andrica-Ionascu links for more comments.
The integral formula (3.6) in Andrica-Vacaretu (see Theorem 3 of the INTEGERS 2013 slides which has a typo) gives in this case the number of representations of n as +- 1^2 +- 2^2 +- ... +- k^2 for some choice of +- signs. This integral formula is (2^n/2*Pi)*Integral_{t=0..2*Pi} cos(n*t) * Product_{j=1..k} cos(j^2*t) dt. Clearly the number of such representations of n is the coefficient of z^n in the expansion (z^(1^2) + z^(-1^2))*(z^(2^2) + z^(-2^2))*...*(z^(k^2) + z^(-k^2)). Andrica-Vacaretu used this generating function to prove the integral formula. Section 4 of Andrica-Vacaretu gives a table of the number of such representations of n for k=1,...,9. - Dorin Andrica, Nov 12 2013

Examples

			0 = 1^2 + 2^2 - 3^2 + 4^2 - 5^2 - 6^2 + 7^2.
1 = 1^2.
2 = - 1^2 - 2^2 - 3^2 + 4^2.
3 = - 1^2 + 2^2.
4 = - 1^2 - 2^2 + 3^2.
		

Crossrefs

Programs

  • Maple
    b:= proc(n, i) option remember; local m; m:=i*(i+1)*(2*i+1)/6;
          n<=m and (n=m or b(n+i^2, i-1) or b(abs(n-i^2), i-1))
        end:
    a:= proc(n) local k; for k while not b(n, k) do od; k end:
    seq(a(n), n=0..100);  # Alois P. Heinz, Nov 03 2013
  • Mathematica
    b[n_, i_] := b[n, i] = Module[{m}, m = i*(i+1)*(2*i+1)/6; n <= m && (n == m || b[n+i^2, i-1] || b[Abs[n-i^2], i-1])]; a[n_] := Module[{k}, For[k = 1, !b[n, k] , k++]; k]; Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Jan 28 2014, after Alois P. Heinz *)

Formula

a(n(n+1)(2n+1)/6) = a(A000330(n)) = n for n > 0.
a((n(n+1)(2n+1)/6)-2) = a(A000330(n)-2) = n for n > 0.

Extensions

a(4) corrected and a(5)-a(85) from Donovan Johnson, Nov 03 2013

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)

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

Views

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-3 of 3 results.