%I #66 Feb 01 2023 02:31:34
%S 1,2,1,-2,-4,-2,3,6,3,-4,-8,-4,5,10,5,-6,-12,-6,7,14,7,-8,-16,-8,9,18,
%T 9,-10,-20,-10,11,22,11,-12,-24,-12,13,26,13,-14,-28,-14,15,30,15,-16,
%U -32,-16,17,34,17,-18,-36,-18,19,38,19,-20,-40,-20,21,42,21
%N Self-convolution of A010892. The g.f. is 1/(Alexander polynomial of granny knot).
%C A granny knot sequence.
%C INVERTi transform of A077855: (1, 3, 6, 11, 20, 36, 64, 133, ...). - _Gary W. Adamson_, Jan 13 2017
%H A.H.M. Smeets, <a href="/A099254/b099254.txt">Table of n, a(n) for n = 0..20000</a>
%H <a href="/index/Rec#order_04">Index entries for linear recurrences with constant coefficients</a>, signature (2,-3,2,-1).
%F G.f.: 1/(1 - 2*x + 3*x^2 - 2*x^3 + x^4) = 1/(1 - x + x^2)^2.
%F a(n) = 4*sqrt(3)*sin(Pi*n/3 + Pi/3)/9 + 2*(n + 1)*sin(Pi*n/3 + Pi/6)/3.
%F a(n) = Sum_{k=0..floor(n/2)} binomial(n-k,k)*(n-k+1)*(-1)^k. - _Paul Barry_, Nov 12 2004
%F a(n) = 2*cos(2*Pi*(n + 2)/3)*(floor(n/3) + 1)*(-1)^(n+1). - _Tani Akinari_, Jul 01 2013
%F a(n) = (1/54)*(18*(n + 2)*(-1)^floor(n/3) + (3*n + 11)*(-1)^floor((n + 1)/3) - 9*(n + 1)*(-1)^floor((n + 2)/3) - 2*(3*n + 8)*(-1)^floor((n + 4)/3)). - _John M. Campbell_, Dec 23 2016
%F From _A.H.M. Smeets_, Sep 13 2018: (Start)
%F a(n) = 2*a(n-1) - 3*a(n-2) + 2*a(n-3) - a(n-4) for n >= 4.
%F a(3*k) = a(3*k+2) = (-1)^k*(k + 1) for k >= 0.
%F a(3*k+1) = -(-1)^k*2*(k + 1) for k >= 0. (End)
%p A099254 := proc(n)
%p option remember ;
%p if n <= 3 then
%p op(n+1,[1,2,1,-2]) ;
%p else
%p 2*procname(n-1)-3*procname(n-2)+2*procname(n-3)-procname(n-4) ;
%p end if;
%p end proc:
%p seq(A099254(n),n=0..80) ; # _R. J. Mathar_, Jul 08 2022
%t LinearRecurrence[{2, -3, 2, -1}, {1, 2, 1, -2}, 100] (* _Jean-François Alcover_, Sep 21 2022 *)
%o (Python)
%o a0,a1,a2,a3,n = -2,1,2,1,3
%o print(0,a3)
%o print(1,a2)
%o print(2,a1)
%o print(3,a0)
%o while n < 20000:
%o a0,a1,a2,a3,n = 2*a0-3*a1+2*a2-a3,a0,a1,a2,n+1
%o print(n,a0) # _A.H.M. Smeets_, Sep 13 2018
%o (Python)
%o def A099254(n):
%o a, b = divmod(n,3)
%o return (1+(b&1))*(-a-1 if a&1 else a+1) # _Chai Wah Wu_, Jan 31 2023
%Y Row sums of array A128502.
%Y Cf. A077855, A076118 (first differences).
%K sign,easy
%O 0,2
%A _Paul Barry_, Oct 08 2004