OFFSET
0,2
COMMENTS
If n is odd, n^2 is counted twice.
LINKS
Harry J. Smith, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (3,-2,-2,3,-1).
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) { for (n=0, 1000, write("b059924.txt", n, " ", floor((16*n^3 - 6*n^2 + 8*n + 3 - 3*(-1^n))/12)); ) } \\ Harry J. Smith, Jun 30 2009
CROSSREFS
KEYWORD
easy,nice,nonn
AUTHOR
Fabian Rothelius, Feb 10 2001
EXTENSIONS
Corrected and extended by Eric Werley, Jun 30 2011
STATUS
approved