OFFSET
0,2
LINKS
Bruno Berselli, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (3,-2,-1,1).
FORMULA
a(n) = a(n-2) + a(n-1) + n - 2 with n>1, a(0)=1, a(1)=2. - Alex Ratushnyak, May 02 2012
From Bruno Berselli, May 03 2012: (Start)
G.f.: (1-x-x^2+2*x^3)/((1-x-x^2)*(1-x)^2). - Bruno Berselli, May 03 2012
EXAMPLE
MATHEMATICA
LinearRecurrence[{3, -2, -1, 1}, {1, 2, 3, 6}, 41] (* Bruno Berselli, May 03 2012 *)
Table[2*Fibonacci[n+2]-n-1, {n, 0, 40}] (* G. C. Greubel, Jul 09 2019 *)
PROG
(Python)
prpr = 1
prev = 2
for n in range(2, 99):
current = prpr + prev + n - 2
print(prpr, end=', ')
prpr = prev
prev = current # Alex Ratushnyak, May 02 2012
(PARI) Vec((1-x-x^2+2*x^3)/((1-x-x^2)*(1-x)^2)+O(x^40)) \\ Bruno Berselli, May 03 2012
(PARI) vector(40, n, n--; 2*fibonacci(n+2)-n-1) \\ G. C. Greubel, Jul 09 2019
(Magma) /* By the first comment: */ [&+[2*Binomial(n-Floor((k+1)/2), Floor(k/2))-1: k in [0..n]]: n in [0..40]]; /* Bruno Berselli, May 03 2012 */
(Magma) [2*Fibonacci(n+2)-n-1: n in [0..40]]; // G. C. Greubel, Jul 09 2019
(Maxima) makelist(expand(((1+sqrt(5))^(n+2)-(1-sqrt(5))^(n+2) )/(2^(n+1)*sqrt(5))-n-1), n, 0, 40); /* Bruno Berselli, May 03 2012 */
(Sage) [2*fibonacci(n+2)-n-1 for n in (0..40)] # G. C. Greubel, Jul 09 2019
(GAP) List([0..40], n-> 2*Fibonacci(n+2)-n-1); # G. C. Greubel, Jul 09 2019
CROSSREFS
KEYWORD
nonn,easy,changed
AUTHOR
Gary W. Adamson, Jun 23 2007
EXTENSIONS
Better definition and more terms from Bruno Berselli, May 03 2012
STATUS
approved