%I #98 Sep 06 2022 10:31:05
%S 0,3,14,33,60,95,138,189,248,315,390,473,564,663,770,885,1008,1139,
%T 1278,1425,1580,1743,1914,2093,2280,2475,2678,2889,3108,3335,3570,
%U 3813,4064,4323,4590,4865,5148,5439,5738,6045,6360,6683,7014,7353,7700,8055,8418
%N a(n) = n*(4*n-1).
%C Write 0,1,2,... in a clockwise spiral; sequence gives numbers on negative x axis. (See illustration in Example.)
%C 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
%C From _Emeric Deutsch_, Sep 21 2010: (Start)
%C a(n) is also the Wiener index of the windmill graph D(3,n).
%C 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.
%C 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)
%C Even hexagonal numbers divided by 2. - _Omar E. Pol_, Aug 18 2011
%C 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
%C 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
%D S. M. Ellerstein, The square spiral, J. Recreational Mathematics 29 (#3, 1998) 188; 30 (#4, 1999-2000), 246-250.
%D R. L. Graham, D. E. Knuth and O. Patashnik, Concrete Mathematics. Addison-Wesley, Reading, MA, 2nd ed., 1994, p. 99.
%H Harvey P. Dale, <a href="/A033991/b033991.txt">Table of n, a(n) for n = 0..1000</a>
%H Emilio Apricena, <a href="/A035608/a035608.png">A version of the Ulam spiral</a>.
%H Eric W. Weisstein, <a href="http://mathworld.wolfram.com/WindmillGraph.html">Windmill Graph</a>.
%H <a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (3,-3,1).
%F a(n) = A007742(-n) = A074378(2n-1) = A014848(2n).
%F G.f.: x*(3+5*x)/(1-x)^3. - _Michael Somos_, Mar 03 2003
%F a(n) = A014635(n)/2. - _Zerinvary Lajos_, Jan 16 2007
%F From _Zerinvary Lajos_, Jun 12 2007: (Start)
%F a(n) = A000326(n) + A005476(n).
%F a(n) = A049452(n) - A001105(n). (End)
%F a(n) = 3*a(n-1) - 3*a(n-2) + a(n-3) for n > 2. - _Harvey P. Dale_, Oct 10 2011
%F a(n) = A118729(8n+2). - _Philippe Deléham_, Mar 26 2013
%F From _Ilya Gutkovskiy_, Dec 04 2016: (Start)
%F E.g.f.: x*(3 + 4*x)*exp(x).
%F Sum_{n>=1} 1/a(n) = 3*log(2) - Pi/2 = 0.50864521488... (End)
%F a(n) = Sum_{i=n..3n-1} i. - _Wesley Ivan Hurt_, Dec 04 2016
%F From _Franck Maminirina Ramaharo_, Mar 09 2018: (Start)
%F a(n) = binomial(2*n, 2) + 2*n^2.
%F a(n) = A054556(n+1) - 1. (End)
%F Sum_{n>=1} (-1)^(n+1)/a(n) = (Pi + log(3-2*sqrt(2)))/sqrt(2) - log(2). - _Amiram Eldar_, Mar 20 2022
%e Clockwise spiral (with sequence terms parenthesized) begins
%e 16--17--18--19
%e |
%e 15 4---5---6
%e | | |
%e (14) (3) (0) 7
%e | | | |
%e 13 2---1 8
%e | |
%e 12--11--10---9
%p [seq(binomial(4*n, 2)/2, n=0..45)]; # _Zerinvary Lajos_, Jan 16 2007
%t Table[n*(4*n - 1), {n, 0, 100}] (* _Vladimir Joseph Stephan Orlovsky_, Jul 06 2011 *)
%t LinearRecurrence[{3,-3,1},{0,3,14},50] (* _Harvey P. Dale_, Oct 10 2011 *)
%o (PARI) a(n)=4*n^2-n;
%Y Sequences from spirals: A001107, A002939, A007742, A033951-A033954, A033989-A033991, A002943, A033996, A033988.
%Y Sequences on the four axes of the square spiral: Starting at 0: A001107, A033991, A007742, A033954; starting at 1: A054552, A054556, A054567, A033951.
%Y 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.
%Y 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.
%Y Cf. A074378, A014848, A152743, A028994, A000326, A001105, A005476, A014635, A016742, A049452, A118729.
%K nonn,easy,nice
%O 0,2
%A _N. J. A. Sloane_
%E Two remarks combined into one by _Emeric Deutsch_, Oct 03 2010