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

A248509 Length of longest sequence of distinct nonzero squares summing to n, or 0 if no such sequence exists.

Original entry on oeis.org

1, 0, 0, 1, 2, 0, 0, 0, 1, 2, 0, 0, 2, 3, 0, 1, 2, 0, 0, 2, 3, 0, 0, 0, 2, 3, 0, 0, 3, 4, 0, 0, 0, 2, 3, 1, 2, 3, 4, 2, 3, 3, 0, 0, 3, 4, 0, 0, 3, 4, 4, 2, 3, 4, 5, 3, 4, 2, 3, 0, 3, 4, 4, 1, 4, 5, 0, 2, 3, 4, 4, 0, 2, 4, 5, 0, 3, 4, 5, 2, 4, 5, 3, 4
Offset: 1

Views

Author

Robert Israel, Oct 07 2014

Keywords

Comments

a(n) >= k for n > A129210(k).
a(n) > 0 iff A033461(n) > 0. - Reinhard Zumkeller, Oct 07 2014

Examples

			1 = 1^2 so a(1) = 1.
2 and 3 are not sums of distinct squares, so a(2) = 0 and a(3) = 0.
4 = 2^2 so a(4) = 1.
5 = 1^2 + 2^2 so a(5) = 2.
		

Crossrefs

Cf. A129210.
Cf. A033461.

Programs

  • Maple
    N:= 100: # to get a(1) to a(N)
    M:= floor(sqrt(N)):
    A:= Array(0..N,0..M):
    sj:= unapply(sum(k^2,k=1..x),x):
    for j from 1 to M do
      for n from sj(j)+1 to N do A[n,j]:= -infinity od:
      for n from 1 to j^2-1 do A[n,j]:= A[n,j-1] od:
      for n from j^2 to min(sj(j),N) do A[n,j]:= max(A[n,j-1],1+A[n-j^2,j-1]) od:
    od:
    subs(-infinity=0,[seq(A[n,M],n=1..N)]); # Robert Israel, Oct 07 2014
  • Mathematica
    Nt = 100 (* = number of terms *);
    M = Floor[Sqrt[Nt]];
    Clear[A]; A[, ] = 0;
    s[j_] := Range[j].Range[j];
    For[j = 1, j <= M, j++,
      For[n = s[j] + 1, n <= Nt, n++, A[n, j] = -Infinity];
      For[n = 1, n <= j^2 - 1, n++, A[n, j] = A[n, j - 1]];
      For[n = j^2, n <= Min[s[j], Nt], n++, A[n, j] = Max[A[n, j-1], 1+A[nj^2, j-1]]]
    ];
    Table[A[n, M] /. DirectedInfinity[-1] -> 0, {n, 1, Nt}] (* Jean-François Alcover, Mar 04 2019, after Robert Israel *)

A362110 a(n) is the smallest integer k such that n can be expressed as the arithmetic mean of k distinct nonzero squares, or 0 if no such k exists.

Original entry on oeis.org

1, 0, 0, 1, 2, 0, 3, 0, 1, 2, 5, 0, 2, 3, 3, 1, 2, 3, 5, 2, 4, 3, 3, 5, 1, 2, 3, 3, 2, 3, 3, 5, 5, 2, 3, 1, 2, 3, 3, 2, 2, 3, 3, 5, 2, 3, 3, 5, 1, 2, 3, 2, 2, 3, 3, 3, 3, 2, 4, 3, 2, 3, 3, 1, 2, 3, 3, 2, 4, 3, 3, 3, 2, 2, 3, 5, 4, 3, 3, 2, 1, 2, 3, 4, 2, 3, 3, 3, 2, 2, 3, 3, 4, 3, 3, 5, 2, 3, 3
Offset: 1

Views

Author

Yifan Xie, Apr 16 2023

Keywords

Examples

			For n = 2, if k = 1, 2*1 = 2 is not a square; but, from the upper bound formula, (k + 1) * (2*k + 1) <= 12, so k <= 1. So, a satisfactory k does not exist; hence a(2) = 0.
		

Crossrefs

Cf. A360530 (allows repeated squares).

Formula

Upper bound: (a(n) + 1) * (2*a(n) + 1) <= 6*n. Proof: Because (Sum_{m=1..k} (i_m)^2)/k = n, n*k = Sum_{m=1..k} (i_m)^2. Since each i_m is distinct, n*k >= Sum_{m=1..k} m^2 = k * (k + 1) * (2*k + 1)/6, hence (k + 1) * (2*k + 1) <= 6*n.
a(A132777(n)) = 2. - Thomas Scheuerle, Apr 16 2023

Extensions

Name qualified and other edits by Peter Munn, Apr 21 2023
Showing 1-2 of 2 results.