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.
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
Keywords
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.
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
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 *)
Comments