login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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. 2
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 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,3

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

LINKS

Robert Israel, Table of n, a(n) for n = 0..10000

Rémy Sigrist, C program for A307531

Wikipedia, Lagrange's four-square theorem

EXAMPLE

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.

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 *)

PROG

(C) See Links section.

CROSSREFS

See A307510 for the multiplicative variant.

Cf. A002635.

Sequence in context: A114524 A058033 A216197 * A125619 A262519 A225320

Adjacent sequences:  A307528 A307529 A307530 * A307532 A307533 A307534

KEYWORD

nonn

AUTHOR

Rémy Sigrist, Apr 13 2019

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified October 16 13:51 EDT 2019. Contains 328093 sequences. (Running on oeis4.)