Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #28 Dec 30 2024 22:43:30
%S 0,2,10,34,80,158,274,438,656,938,1290,1722,2240,2854,3570,4398,5344,
%T 6418,7626,8978,10480,12142,13970,15974,18160,20538,23114,25898,28896,
%U 32118,35570,39262,43200,47394,51850,56578,61584,66878,72466,78358,84560,91082,97930
%N Write the numbers from 1 to n^2 in a spiraling square; a(n) is the total of the sums of the two diagonals.
%C If n is odd, n^2 is counted twice.
%H Harry J. Smith, <a href="/A059924/b059924.txt">Table of n, a(n) for n = 0..1000</a>
%H <a href="/index/Rec#order_05">Index entries for linear recurrences with constant coefficients</a>, signature (3,-2,-2,3,-1).
%F a(n) = 3a(n-1)-2a(n-2)-2a(n-3)+3a(n-4)-a(n-5), a(0) = 0, a(1) = 2, a(2) = 10, a(3) = 34, a(4) = 80.
%F a(n) = (16*n^3 - 6*n^2 + 8*n + 3 - 3*(-1)^n)/12. - _Frank Ellermann_, Mar 16 2002
%F O.g.f.: (2*x+4*x^2+8*x^3+2*x^4)/(1-3*x+2*x^2+2*x^3-3*x^4+x^5)=(2*x+4*x^2+8*x^3+2*x^4)/((1-x)^4*(1+x)). - _Eric Werley_, Jun 30 2011
%e Write the numbers from 1 to 16 like this:
%e .
%e 1---2---3---4
%e |
%e 12--13--14 5
%e | | |
%e 11 16--15 6
%e | |
%e 10---9---8---7
%e .
%e The two diagonals add to 36 and 44, so a(4) = 36 + 44 = 80.
%t LinearRecurrence[{3,-2,-2,3,-1},{0,2,10,34,80},40] (* _Harvey P. Dale_, Mar 23 2012 *)
%o (PARI) a(n) = { (16*n^3 - 6*n^2 + 8*n + 3 - 3*(-1)^n)/12 } \\ _Harry J. Smith_, Jun 30 2009
%K easy,nice,nonn
%O 0,2
%A _Fabian Rothelius_, Feb 10 2001
%E Corrected and extended by _Eric Werley_, Jun 30 2011