OFFSET
0,2
COMMENTS
Write 0,1,2,... in a clockwise spiral; sequence gives numbers on negative x axis. (See illustration in Example.)
This sequence is the number of expressions x generated for a given modulus n in finite arithmetic. For example, n=1 (modulus 1) generates 3 expressions: 0+0=0(mod 1), 0-0=0(mod 1), 0*0=0(mod 1). By subtracting n from 4n^2, we eliminate the counting of those expressions that would include division by zero, which would be, of course, undefined. - David Quentin Dauthier, Nov 04 2007
From Emeric Deutsch, Sep 21 2010: (Start)
a(n) is also the Wiener index of the windmill graph D(3,n).
The windmill graph D(m,n) is the graph obtained by taking n copies of the complete graph K_m with a vertex in common (i.e., a bouquet of n pieces of K_m graphs). The Wiener index of a connected graph is the sum of the distances between all unordered pairs of vertices in the graph.
Example: a(2)=14; indeed if the triangles are OAB and OCD, then, denoting distance by d, we have d(O,A)=d(O,B)=d(A,B)=d(O,C)=d(O,D)=d(C,D)=1 and d(A,C)=d(A,D)=d(B,C)=d(B,D)=2. The Wiener index of D(m,n) is (1/2)n(m-1)[(m-1)(2n-1)+1]. For the Wiener indices of D(4,n), D(5,n), and D(6,n) see A152743, A028994, and A180577, respectively. (End)
Even hexagonal numbers divided by 2. - Omar E. Pol, Aug 18 2011
For n > 0, a(n) equals the number of length 3*n binary words having exactly two 0's with the n first bits having at most one 0. For example a(2) = 14. Words are 010111, 011011, 011101, 011110, 100111, 101011, 101101, 101110, 110011, 110101, 110110, 111001, 111010, 111100. - Franck Maminirina Ramaharo, Mar 09 2018
For n >= 1, the continued fraction expansion of sqrt(a(n)) is [2n-1; {1, 2, 1, 4n-2}]. For n=1, this collapses to [1; {1, 2}]. - Magus K. Chu, Sep 06 2022
REFERENCES
S. M. Ellerstein, The square spiral, J. Recreational Mathematics 29 (#3, 1998) 188; 30 (#4, 1999-2000), 246-250.
R. L. Graham, D. E. Knuth and O. Patashnik, Concrete Mathematics. Addison-Wesley, Reading, MA, 2nd ed., 1994, p. 99.
LINKS
Harvey P. Dale, Table of n, a(n) for n = 0..1000
Emilio Apricena, A version of the Ulam spiral.
Eric W. Weisstein, Windmill Graph.
Index entries for linear recurrences with constant coefficients, signature (3,-3,1).
FORMULA
G.f.: x*(3+5*x)/(1-x)^3. - Michael Somos, Mar 03 2003
a(n) = A014635(n)/2. - Zerinvary Lajos, Jan 16 2007
From Zerinvary Lajos, Jun 12 2007: (Start)
a(n) = 3*a(n-1) - 3*a(n-2) + a(n-3) for n > 2. - Harvey P. Dale, Oct 10 2011
a(n) = A118729(8n+2). - Philippe Deléham, Mar 26 2013
From Ilya Gutkovskiy, Dec 04 2016: (Start)
E.g.f.: x*(3 + 4*x)*exp(x).
Sum_{n>=1} 1/a(n) = 3*log(2) - Pi/2 = 0.50864521488... (End)
a(n) = Sum_{i=n..3n-1} i. - Wesley Ivan Hurt, Dec 04 2016
From Franck Maminirina Ramaharo, Mar 09 2018: (Start)
a(n) = binomial(2*n, 2) + 2*n^2.
a(n) = A054556(n+1) - 1. (End)
Sum_{n>=1} (-1)^(n+1)/a(n) = (Pi + log(3-2*sqrt(2)))/sqrt(2) - log(2). - Amiram Eldar, Mar 20 2022
EXAMPLE
Clockwise spiral (with sequence terms parenthesized) begins
16--17--18--19
|
15 4---5---6
| | |
(14) (3) (0) 7
| | | |
13 2---1 8
| |
12--11--10---9
MAPLE
[seq(binomial(4*n, 2)/2, n=0..45)]; # Zerinvary Lajos, Jan 16 2007
MATHEMATICA
Table[n*(4*n - 1), {n, 0, 100}] (* Vladimir Joseph Stephan Orlovsky, Jul 06 2011 *)
LinearRecurrence[{3, -3, 1}, {0, 3, 14}, 50] (* Harvey P. Dale, Oct 10 2011 *)
PROG
(PARI) a(n)=4*n^2-n;
CROSSREFS
Sequences from spirals: A001107, A002939, A007742, A033951-A033954, A033989-A033991, A002943, A033996, A033988.
Sequences on the four axes of the square spiral: Starting at 0: A001107, A033991, A007742, A033954; starting at 1: A054552, A054556, A054567, A033951.
Sequences on the four diagonals of the square spiral: Starting at 0: A002939 = 2*A000384, A016742 = 4*A000290, A002943 = 2*A014105, A033996 = 8*A000217; starting at 1: A054554, A053755, A054569, A016754.
Sequences obtained by reading alternate terms on the X and Y axes and the two main diagonals of the square spiral: Starting at 0: A035608, A156859, A002378 = 2*A000217, A137932 = 4*A002620; starting at 1: A317186, A267682, A002061, A080335.
KEYWORD
nonn,easy,nice
AUTHOR
EXTENSIONS
Two remarks combined into one by Emeric Deutsch, Oct 03 2010
STATUS
approved