OFFSET
0,3
LINKS
Harvey P. Dale, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (2,0,-2,1).
FORMULA
G.f.: (x + 2*x^2 - 2*x^3) / ((1 - x)^2 * (1 - x^2)).
a(n) = a(n-2)+n (mod a(n-1)+n) with n>=2 and initial values (1, 1).
a(n) = 2*a(n-1) - 2*a(n-3) + a(n-4), a(0)=0, a(1)=1, a(2)=4, a(3)=6. - Harvey P. Dale, Apr 20 2015
a(n) = (2*n*(n+6)-3*(1-(-1)^n))/8. - Luce ETIENNE, Jun 05 2015
EXAMPLE
G.f. = x + 4*x^2 + 6*x^3 + 10*x^4 + 13*x^5 + 18*x^6 + 22*x^7 + 28*x^8 + 33*x^9 + ...
Here b=2; a(0)=a(1)=1. a(2)= a(0)+2 (mod a(1)+2) = 3 (mod 3) =0 a(3)= a(1)+3 (mod a(2)+3) = 4 (mod 3) =1 a(4)= a(2)+4 (mod a(3)+4) = 4 (mod 5) =4 etc... we get 6, 13, 18, ...
MAPLE
a:= n-> (Matrix([[4, 1, 0, -2]]). Matrix(4, (i, j)-> if (i=j-1) then 1 elif j=1 then [2, 0, -2, 1][i] else 0 fi)^n)[1, 4]: seq(a(n), n=1..60); # Alois P. Heinz, Aug 06 2008
MATHEMATICA
b = 2; aa = {1, 1}; Do[AppendTo[aa, Mod[ aa[[ -2]] + n, aa[[ -1]] + n]], {n, b, 50}]; Drop[aa, 2]
CoefficientList[Series[(x+2*x^2-2*x^3)/((1-x)^2*(1-x^2)), {x, 0, 60}], x]
LinearRecurrence[{2, 0, -2, 1}, {0, 1, 4, 6}, 50] (* Harvey P. Dale, Apr 20 2015 *)
PROG
(PARI) my(x='x+O('x^50)); concat([0], Vec( (x+2*x^2-2*x^3)/((1-x)^2*(1- x^2)) )) \\ G. C. Greubel, Jan 15 2019
(Magma) m:=50; R<x>:=PowerSeriesRing(Integers(), m); [0] cat Coefficients(R!( (x+2*x^2-2*x^3)/((1-x)^2*(1- x^2)) )); // G. C. Greubel, Jan 15 2019
(Sage) ((x+2*x^2-2*x^3)/((1-x)^2*(1- x^2))).series(x, 50).coefficients(x, sparse=False) # G. C. Greubel, Jan 15 2019
(GAP) a:=[0, 1, 4, 6];; for n in [5..50] do a[n]:=2*a[n-1]-2*a[n-3]+a[n-4]; od; a; # G. C. Greubel, Jan 15 2019
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Carlos Alves, Jan 21 2003
STATUS
approved