login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Integers of the form 8k+7 that can be written as a sum of four distinct 'almost consecutive' squares.
6

%I #41 Feb 08 2024 09:47:08

%S 39,71,87,119,191,255,287,351,471,567,615,711,879,1007,1071,1199,1415,

%T 1575,1655,1815,2079,2271,2367,2559,2871,3095,3207,3431,3791,4047,

%U 4175,4431,4839,5127,5271,5559,6015,6335,6495,6815,7319,7671,7847,8199,8751,9135,9327,9711

%N Integers of the form 8k+7 that can be written as a sum of four distinct 'almost consecutive' squares.

%C 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.

%C From now on assume that n is of the form 8k+7 and is a sum of distinct squares a,b,c,d, sorted.

%C 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

%C 39, [1,2,3,5], with gap pattern 112,

%C 71, [1,3,5,6], with gap pattern 221,

%C 87, [2,3,5,7], with gap pattern 122,

%C 119, [3,5,6,7], with gap pattern 211,

%C 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:

%C [1,2,3,5] = [1,1,2,3] + [4,0,0,0] or

%C [1,2,3,5] = [1,1,2,3] + [0,4,0,0]

%C [1,3,5,6] = [1,1,2,3] + [0,4,4,0]

%C [2,3,5,7] = [1,2,3,3] + [4,0,4,0] or

%C [2,3,5,7] = [1,2,3,3] + [4,0,0,4]

%C [3,5,6,7] = [1,2,3,3] + [4,4,4,0] or

%C [3,5,6,7] = [1,2,3,3] + [4,4,0,4].

%C There are generators for other gap patterns, but the minimal gap patterns are of the most interest. - _Walter Kehowski_, Jul 07 2014

%H Walter Kehowski, <a href="/A243577/b243577.txt">Table of n, a(n) for n = 1..1728</a>

%H J. O. Sizemore, <a href="http://www.math.wisc.edu/~josizemore/Notes16%284-square%29.pdf">Lagrange's Four Square Theorem</a>

%H R. C. Vaughan, <a href="https://personal.science.psu.edu/rcv4/Foursq.pdf">Lagrange's Four Square Theorem</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/LagrangesFour-SquareTheorem.html">Lagrange's Four-Square Theorem</a>

%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Lagrange%27s_four-square_theorem">Lagrange's four-square theorem</a>

%H <a href="/index/Rec#order_07">Index entries for linear recurrences with constant coefficients</a>, signature (3,-5,7,-7,5,-3,1).

%F If n mod 4 = 1, then a(n) = 4*n^2 + 14*n + 21.

%F If n mod 4 = 2, then a(n) = 4*n^2 + 14*n + 27.

%F If n mod 4 = 3, then a(n) = 4*n^2 + 10*n + 21.

%F If n mod 4 = 0, then a(n) = 4*n^2 + 10*n + 15.

%F 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

%F 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

%e For n=1, a(n) = 4*1^2 + 14*1 + 21 = 39 and 39 = 1^2 + 2^2 + 3^2 + 5^2.

%e For n=2, a(n) = 4*2^2 + 14*2 + 27 = 39 and 71 = 1^2 + 3^2 + 5^2 + 6^2.

%e For n=3, a(n) = 4*3^2 + 10*3 + 21 = 87 and 87 = 2^2 + 3^2 + 5^2 + 7^2.

%e For n=4, a(n) = 4*4^2 + 10*4 + 15 = 119 and 119 = 3^2 + 5^2 + 6^2 + 7^2.

%p A243577 := proc(n::posint)

%p if n mod 4 = 1 then

%p return [4*n^2+14*n+21, [n,n+1,n+2,n+4]]

%p elif n mod 4 = 2 then

%p return [4*n^2+14*n+27, [n-1,n+1,n+3,n+4]]

%p elif n mod 4 = 3 then

%p return [4*n^2+10*n+21, [n-1,n,n+2,n+4]]

%p else

%p return [4*n^2+10*n+15, [n-1,n+1,n+2,n+3]]

%p fi;

%p end:

%p # _Walter A. Kehowski_, Jun 08 2014

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

%t LinearRecurrence[{3,-5,7,-7,5,-3,1},{39,71,87,119,191,255,287},50] (* _Harvey P. Dale_, Jul 05 2021 *)

%o (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

%Y Cf. A004771, A008586, A016813, A016825, A243578, A243579, A243580, A243581, A243582.

%K nonn,easy

%O 1,1

%A _Walter Kehowski_, Jun 08 2014