OFFSET
0,3
REFERENCES
J. H. Conway, The Sensual Quadratic Form, Mathematical Association of America, 1997, p. 4.
G. L. Watson, Integral Quadratic Forms, Cambridge University Press, p. 2.
LINKS
Index entries for linear recurrences with constant coefficients, signature (0,-2,0,-1).
FORMULA
a(2n) = (-1)^n*(2*n+1), a(2n+1) = (-1)^n*(n+1). Or (apart from signs and with offset 1), a(n) = n, n odd; n/2, n even.
G.f.: (1+x-x^2)/(1+x^2)^2. - Len Smiley
a(-2-n) = (-1)^n * a(n). - Michael Somos, Jun 15 2005
a(n) = -2*a(n-2) - a(n-4); a(0)=1, a(1)=1, a(2)=-3, a(3)=-2. - Harvey P. Dale, Dec 02 2011
a(n) = (-1)^floor(n/2)*A026741(n+1).
EXAMPLE
G.f. = 1 + x - 3*x^2 - 2*x^3 + 5*x^4 + 3*x^5 - 7*x^6 - 4*x^7 + 8*x^9 + 5*x^10 + ...
MATHEMATICA
CoefficientList[Series[(1+x-x^2)/(1+x^2)^2, {x, 0, 60}], x] (* or *) LinearRecurrence[{0, -2, 0, -1}, {1, 1, -3, -2}, 70]
a[ n_] := With[{m = n + 1}, m I^m / If[ Mod[ m, 2] == 1, I, -2]]; (* Michael Somos, Jun 11 2013 *)
PROG
(PARI) {a(n) = if( n==-1, 0, (-1)^(n\2) * (n+1) / gcd(n+1, 2))}; /* Michael Somos, Jun 15 2005 */
(Python)
def A030640(n): return (-(n+1>>1) if n&2 else n+1>>1) if n&1 else (-n-1 if n&2 else n+1) # Chai Wah Wu, Aug 05 2024
CROSSREFS
KEYWORD
sign,easy,nice
AUTHOR
STATUS
approved