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.

A307531 a(n) is the greatest sum i + j + k + l where i^2 + j^2 + k^2 + l^2 = n and 0 <= i <= j <= k <= l.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Apr 13 2019

Keywords

Comments

The sequence is well defined as every nonnegative integer can be represented as a sum of four squares in at least one way.
It appears that a(n^2) = 2*n if n is even and 2*n-1 if n is odd. - Robert Israel, Apr 14 2019

Examples

			For n = 34:
- 34 can be expressed in 4 ways as a sum of four squares:
    i^2 + j^2 + k^2 + l^2   i+j+k+l
    ---------------------   -------
    0^2 + 0^2 + 3^2 + 5^2         8
    0^2 + 3^2 + 3^2 + 4^2        10
    1^2 + 1^2 + 4^2 + 4^2        10
    1^2 + 2^2 + 2^2 + 5^2        10
- a(34) = max(8, 10) = 10.
		

Crossrefs

See A307510 for the multiplicative variant.

Programs

  • C
    See Links section.
  • Maple
    g:= proc(n,k) option remember; local a;
      if k = 1 then if issqr(n) then return sqrt(n) else return -infinity fi fi;
      max(seq(a+procname(n-a^2,k-1),a=0..floor(sqrt(n))))
    end proc:
    seq(g(n,4), n=0..100); # Robert Israel, Apr 14 2019
  • Mathematica
    Array[Max[Total /@ PowersRepresentations[#, 4, 2]] &, 68, 0] (* Michael De Vlieger, Apr 13 2019 *)