OFFSET
0,1
LINKS
Stefano Spezia, Table of n, a(n) for n = 0..10000
Index entries for linear recurrences with constant coefficients, signature (1,1,-1).
FORMULA
G.f.: (2-2x+x^2)/((1-x)(1-x^2)).
a(2n+1)=n. a(2n)=n+2. a(n+2)=a(n)+1. a(n)=-a(-3-n).
a(n) = floor(n/2) + 1 + (-1)^n. - Reinhard Zumkeller, Aug 27 2005
A112032(n)=2^a(n); A112033(n)=3*2^a(n); a(n)=A109613(n+2)-A052938(n). - Reinhard Zumkeller, Aug 27 2005
a(n) = n + 1 - a(n-1) (with a(0)=2). - Vincenzo Librandi, Aug 08 2010
a(n) = floor(n/2)*3 - floor((n-1)/2)*2. - Ross La Haye, Mar 27 2013
a(n) = 3*n - 3 - 5*floor((n-1)/2). - Wesley Ivan Hurt, Nov 08 2013
a(n) = (3 + 5*(-1)^n + 2*n)/4. - Wolfgang Hintze, Dec 13 2014
E.g.f.: ((4 + x)*cosh(x) - (1 - x)*sinh(x))/2. - Stefano Spezia, Jul 01 2023
MAPLE
MATHEMATICA
lst={}; a=1; Do[a=n-a; AppendTo[lst, a], {n, 0, 100}]; lst (* Vladimir Joseph Stephan Orlovsky, Dec 14 2008 *)
Table[{n, n-2}, {n, 2, 40}]//Flatten (* or *) LinearRecurrence[{1, 1, -1}, {2, 0, 3}, 80] (* Harvey P. Dale, Sep 12 2021 *)
PROG
(PARI) a(n)=n\2-2*(n%2)+2
(Magma) &cat[ [n+2, n]: n in [0..37] ]; [Klaus Brockhaus, Nov 23 2009]
(Haskell)
import Data.List (transpose)
a084964 n = a084964_list !! n
a084964_list = concat $ transpose [[2..], [0..]]
-- Reinhard Zumkeller, Apr 06 2015
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Michael Somos, Jun 15 2003
EXTENSIONS
First part of definition adjusted to match offset by Klaus Brockhaus, Nov 23 2009
STATUS
approved