OFFSET
0,2
LINKS
Michael De Vlieger, Table of n, a(n) for n = 0..10000
Project Euler, Problem 28. Number Spiral Diagonals
Index entries for linear recurrences with constant coefficients, signature (4,-6,4,-1).
FORMULA
O.g.f.: 3/(-1+x) + 16/(-1+x)^2 + 44/(-1+x)^3 + 32/(-1+x)^4 = (1 + 21*x + 7*x^2 + 3*x^3)/(-1+x)^4. - R. J. Mathar, Feb 10 2008
a(n) = 1 + 10*n^2 + (16*n^3 + 26*n)/3. [Corrected by Arie Groeneveld, Aug 17 2008]
EXAMPLE
For n = 1, the 3 X 3 spiral is
.
7---8---9
|
6 1---2
| |
5---4---3
.
so a(1) = 7 + 9 + 1 + 5 + 3 = 25.
.
For n = 2, the 5 X 5 spiral is
.
21--22--23--24--25
|
20 7---8---9--10
| | |
19 6 1---2 11
| | | |
18 5---4---3 12
| |
17--16--15--14--13
.
so a(2) = 21 + 25 + 7 + 9 + 1 + 5 + 3 + 17 + 13 = 101.
MATHEMATICA
Array[1 + 10 #^2 + (16 #^3 + 26 #)/3 &, 36, 0] (* Michael De Vlieger, Mar 01 2018 *)
PROG
(PARI) a(n) = 1 + 10*n^2 + (16*n^3 + 26*n)/3; \\ Joerg Arndt, Mar 01 2018
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
William A. Tedeschi, Feb 06 2008, Mar 01 2008
STATUS
approved