OFFSET
0,4
COMMENTS
If signs are ignored, continued fraction for tan(1) (cf. A093178).
LINKS
Harry J. Smith, Table of n, a(n) for n = 0..20000
Index entries for linear recurrences with constant coefficients, signature (0,-2,0,-1).
FORMULA
a(n) = (-1)^(n/2) if n is even, n*(-1)^((n-1)/2) if n is odd.
a(n) = -a(n-2) if n is even, 2*a(n-1) - a(n-2) if n is odd. - Michael Somos, Jan 26 2014
From Henry Bottomley, Oct 19 2001: (Start)
a(n) = (n^n mod (n+1))*(-1)^floor(n/2) for n > 0.
a(n) = (-1)^n*(a(n-2) - a(n-1)) - a(n-3) for n > 2. (End)
G.f.: (1+x+x^2-x^3)/(1+x^2)^2.
E.g.f.: (1+x)*cos(x) = U(0) where U(k) = 1 + x - x^2/((2*k+1)*(2*k+2)) * U(k+1). - Sergei N. Gladkovskii, Oct 17 2012 [Edited by Michael Somos, Jan 26 2014]
From James C. McMahon, Oct 12 2023: (Start)
a(0) = 1; for n > 1,
a(n) = a(n-1) * n if n mod 4 = 1,
a(n-1) - n if n mod 4 = 2,
a(n-1) * n if n mod 4 = 3,
a(n-1) + n if n mod 4 = 4. (End)
EXAMPLE
tan(1) = 1.557407724654902230... = 1 + 1/(1 + 1/(1 + 1/(3 + 1/(1 + ...)))). - Harry J. Smith, Jun 15 2009
G.f. = 1 + x - x^2 - 3*x^3 + x^4 + 5*x^5 - x^6 - 7*x^7 + x^8 + 9*x^9 - x^10 + ...
MAPLE
seq(coeff(series(factorial(n)*(1+x)*cos(x), x, n+1), x, n), n=0..90); # Muniru A Asiru, Jul 21 2018
MATHEMATICA
With[{nn=90}, CoefficientList[Series[(1+x)Cos[x], {x, 0, nn}], x]Range[0, nn]!] (* Harvey P. Dale, Jul 15 2012 *)
LinearRecurrence[{0, -2, 0, -1}, {1, 1, -1, -3}, 100] (* Jean-François Alcover, Feb 21 2020 *)
FoldList[If[Mod[#2, 4]==1, #1*#2, If[Mod[#2, 4]==2, #1-#2, If[Mod[#2, 4] ==3, #1*#2, #1+#2]]]&, 1, Range[1, 85]] (* James C. McMahon, Oct 12 2023 *)
PROG
(PARI) {a(n) = (-1)^(n\2) * if( n%2, n, 1)} /* Michael Somos, Oct 16 2006 */
(Magma) m:=50; R<x>:=PowerSeriesRing(Rationals(), m); b:=Coefficients(R!((1+x)*Cos(x))); [Factorial(n-1)*b[n]: n in [1..m]]; // G. C. Greubel, Jul 21 2018
CROSSREFS
KEYWORD
sign,easy,nice
EXTENSIONS
Formula corrected by Olivier Gérard, Mar 15 1997
Definition clarified by Harvey P. Dale, Jul 15 2012
STATUS
approved