login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A059924
Write the numbers from 1 to n^2 in a spiraling square; a(n) is the total of the sums of the two diagonals.
1
0, 2, 10, 34, 80, 158, 274, 438, 656, 938, 1290, 1722, 2240, 2854, 3570, 4398, 5344, 6418, 7626, 8978, 10480, 12142, 13970, 15974, 18160, 20538, 23114, 25898, 28896, 32118, 35570, 39262, 43200, 47394, 51850, 56578, 61584, 66878, 72466, 78358, 84560, 91082, 97930
OFFSET
0,2
COMMENTS
If n is odd, n^2 is counted twice.
FORMULA
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.
a(n) = (16*n^3 - 6*n^2 + 8*n + 3 - 3*(-1)^n)/12. - Frank Ellermann, Mar 16 2002
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
EXAMPLE
Write the numbers from 1 to 16 like this:
.
1---2---3---4
|
12--13--14 5
| | |
11 16--15 6
| |
10---9---8---7
.
The two diagonals add to 36 and 44, so a(4) = 36 + 44 = 80.
MATHEMATICA
LinearRecurrence[{3, -2, -2, 3, -1}, {0, 2, 10, 34, 80}, 40] (* Harvey P. Dale, Mar 23 2012 *)
PROG
(PARI) a(n) = { (16*n^3 - 6*n^2 + 8*n + 3 - 3*(-1)^n)/12 } \\ Harry J. Smith, Jun 30 2009
CROSSREFS
Sequence in context: A043004 A316172 A108100 * A304159 A211905 A022498
KEYWORD
easy,nice,nonn,changed
AUTHOR
Fabian Rothelius, Feb 10 2001
EXTENSIONS
Corrected and extended by Eric Werley, Jun 30 2011
STATUS
approved