OFFSET
1,2
COMMENTS
Alternately add 5 and subtract 2, starting with 1. Apparently this was a test question: Find the next two numbers after 1,6,4,9,7,12,10. - N. J. A. Sloane, Dec 18 2010
LINKS
Vincenzo Librandi, Table of n, a(n) for n = 1..1000
David Klein, What do the NAEP math tests really measure?, Notices Amer. Math. Soc., 58 (No. 1, 2011), 53-55.
Index entries for linear recurrences with constant coefficients, signature (1,1,-1).
FORMULA
a(n) = (6*n + 5 + 7*(-1)^n)/4. - Jon E. Schoenfield, Jun 24 2010
G.f.: x*(1+5*x-3*x^2)/((1+x)(1-x)^2). - Bruno Berselli, Feb 28 2012
Sum_{n>=1} (-1)^(n+1)/a(n) = 1/3 + Pi/(6*sqrt(3)) + log(3)/2. - Amiram Eldar, Feb 23 2023
EXAMPLE
From Muniru A Asiru, Mar 20 2018: (Start)
For n = 2, a(2) = 3*2 - a[2-1] + 1 = 6 - a[1] + 1 = 6 - 1 + 1 = 6.
For n = 3, a(3) = 3*3 - a[3-1] + 1 = 9 - a[2] + 1 = 9 - 6 + 1 = 4.
For n = 4, a(4) = 3*4 - a[4-1] + 1 = 12 - a[3] + 1 = 12 - 4 + 1 = 9.
... (End)
MAPLE
a:= proc(n) option remember: if n = 1 then 1 elif n >= 2 then 3*n - procname(n-1) + 1 fi; end:
seq(a(n), n = 1..70); # Muniru A Asiru, Mar 20 2018
MATHEMATICA
LinearRecurrence[{1, 1, -1}, {1, 6, 4}, 100] (* Vincenzo Librandi, Feb 28 2012 *)
PROG
(PARI) a(n)=(6*n+5+7*(-1)^n)/4 \\ Charles R Greathouse IV, Jan 11 2012
(Magma) I:=[1, 6, 4]; [n le 3 select I[n] else Self(n-1)+Self(n-2)-Self(n-3): n in [1..60]]; // Vincenzo Librandi, Feb 28 2012
(GAP) a:=[1];; for n in [2..80] do a[n]:=3*n-a[n-1]+1; od; a; # Muniru A Asiru, Mar 20 2018
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Vincenzo Librandi, Nov 20 2009
STATUS
approved