OFFSET
1,1
COMMENTS
By Lagrange's Four Square Theorem, any integer n of the form 8k+7 (A004771) can be written as sum of no fewer than four squares. The initial terms 7,15,23,31 are the generating set for A004771 in the sense that if n = a^2 + b^2+ c^2 + d^2, then (a mod 4)^2 + (b mod 4)^2 + (c mod 4)^2 + (d mod 4)^2 is one of 7,15,23,31.
From now on assume that n is of the form 8k+7 and is a sum of distinct squares a,b,c,d, sorted.
We say that [a,b,c,d] is almost consecutive if the differences b-a, c-b, d-c are 1 or 2. The generating set for this sequence is
39, [1,2,3,5], with gap pattern 112,
71, [1,3,5,6], with gap pattern 221,
87, [2,3,5,7], with gap pattern 122,
119, [3,5,6,7], with gap pattern 211,
in the sense that adding [4*i,4*i,4*i,4*i], i >= 0, preserves the gap pattern. It should be noted that the four generators are all obtainable from [1,1,2,3] or [1,2,3,3] by addition of suitable vectors. Let's write it out:
[1,2,3,5] = [1,1,2,3] + [4,0,0,0] or
[1,2,3,5] = [1,1,2,3] + [0,4,0,0]
[1,3,5,6] = [1,1,2,3] + [0,4,4,0]
[2,3,5,7] = [1,2,3,3] + [4,0,4,0] or
[2,3,5,7] = [1,2,3,3] + [4,0,0,4]
[3,5,6,7] = [1,2,3,3] + [4,4,4,0] or
[3,5,6,7] = [1,2,3,3] + [4,4,0,4].
There are generators for other gap patterns, but the minimal gap patterns are of the most interest. - Walter Kehowski, Jul 07 2014
LINKS
Walter Kehowski, Table of n, a(n) for n = 1..1728
J. O. Sizemore, Lagrange's Four Square Theorem
R. C. Vaughan, Lagrange's Four Square Theorem
Eric Weisstein's World of Mathematics, Lagrange's Four-Square Theorem
Wikipedia, Lagrange's four-square theorem
Index entries for linear recurrences with constant coefficients, signature (3,-5,7,-7,5,-3,1).
FORMULA
If n mod 4 = 1, then a(n) = 4*n^2 + 14*n + 21.
If n mod 4 = 2, then a(n) = 4*n^2 + 14*n + 27.
If n mod 4 = 3, then a(n) = 4*n^2 + 10*n + 21.
If n mod 4 = 0, then a(n) = 4*n^2 + 10*n + 15.
a(n) = -3*(-7 + (-i)^n+i^n) - (1-i)*((-6-6*i) + (-i)^n + i*i^n)*n + 4*n^2 where i=sqrt(-1). - Colin Barker, Jun 09 2014
G.f.: -x*(15*x^6 - 30*x^5 + 45*x^4 - 60*x^3 + 69*x^2 - 46*x + 39) / ((x-1)^3*(x^2+1)^2). - Colin Barker, Jun 09 2014
EXAMPLE
For n=1, a(n) = 4*1^2 + 14*1 + 21 = 39 and 39 = 1^2 + 2^2 + 3^2 + 5^2.
For n=2, a(n) = 4*2^2 + 14*2 + 27 = 39 and 71 = 1^2 + 3^2 + 5^2 + 6^2.
For n=3, a(n) = 4*3^2 + 10*3 + 21 = 87 and 87 = 2^2 + 3^2 + 5^2 + 7^2.
For n=4, a(n) = 4*4^2 + 10*4 + 15 = 119 and 119 = 3^2 + 5^2 + 6^2 + 7^2.
MAPLE
A243577 := proc(n::posint)
if n mod 4 = 1 then
return [4*n^2+14*n+21, [n, n+1, n+2, n+4]]
elif n mod 4 = 2 then
return [4*n^2+14*n+27, [n-1, n+1, n+3, n+4]]
elif n mod 4 = 3 then
return [4*n^2+10*n+21, [n-1, n, n+2, n+4]]
else
return [4*n^2+10*n+15, [n-1, n+1, n+2, n+3]]
fi;
end:
# _Walter A. Kehowski_, Jun 08 2014
MATHEMATICA
Rest@ CoefficientList[Series[-x (15 x^6 - 30 x^5 + 45 x^4 - 60 x^3 + 69 x^2 - 46 x + 39)/((x - 1)^3*(x^2 + 1)^2), {x, 0, 48}], x] (* Michael De Vlieger, Feb 19 2019 *)
LinearRecurrence[{3, -5, 7, -7, 5, -3, 1}, {39, 71, 87, 119, 191, 255, 287}, 50] (* Harvey P. Dale, Jul 05 2021 *)
PROG
(PARI) Vec(-x*(15*x^6-30*x^5+45*x^4-60*x^3+69*x^2-46*x+39)/((x-1)^3*(x^2+1)^2) + O(x^100)) \\ Colin Barker, Jun 09 2014
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Walter Kehowski, Jun 08 2014
STATUS
approved