login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

a(n) = a(n-1) + a(n-2) + n (mod 3), with a(1)=a(2)=1.
2

%I #17 Sep 08 2022 08:45:09

%S 1,1,2,4,8,12,21,35,56,92,150,242,393,637,1030,1668,2700,4368,7069,

%T 11439,18508,29948,48458,78406,126865,205273,332138,537412,869552,

%U 1406964,2276517,3683483,5960000,9643484,15603486,25246970,40850457

%N a(n) = a(n-1) + a(n-2) + n (mod 3), with a(1)=a(2)=1.

%H G. C. Greubel, <a href="/A081410/b081410.txt">Table of n, a(n) for n = 1..1000</a>

%H <a href="/index/Rec#order_05">Index entries for linear recurrences with constant coefficients</a>, signature (1,1,1,-1,-1).

%F a(n) = floor(C*F(n)) + b(n) where C=(9-sqrt(5))/4, F(n) is the n-th Fibonacci number and b(n) is the 6-periodic sequence (0, 0, -1, -1, 0, -1).

%F G.f.: (1 + 2*x^4)/((1-x^3)*(1-x-x^2)).

%F a(1)=1, a(2)=1, a(3)=2, a(4)=4, a(5)=8, a(n) = a(n-1) +a(n-2) +a(n-3) - a(n-4) -a(n-5). - _Harvey P. Dale_, Feb 01 2013

%p seq(coeff(series((1+2*x^4)/((1-x^3)*(1-x-x^2)), x, n+1), x, n), n = 0 .. 40); # _G. C. Greubel_, Aug 15 2019

%t RecurrenceTable[{a[1]==a[2]==1,a[n]==a[n-1]+a[n-2]+Mod[n,3]},a,{n,40}] (* or *) LinearRecurrence[{1,1,1,-1,-1},{1,1,2,4,8},40] (* _Harvey P. Dale_, Feb 01 2013 *)

%o (PARI) my(x='x+O('x^40)); Vec((1+2*x^4)/((1-x^3)*(1-x-x^2))) \\ _G. C. Greubel_, Aug 15 2019

%o (Magma) R<x>:=PowerSeriesRing(Integers(), 40); Coefficients(R!( (1+2*x^4)/((1-x^3)*(1-x-x^2)) )); // _G. C. Greubel_, Aug 15 2019

%o (Sage)

%o def A081410_list(prec):

%o P.<x> = PowerSeriesRing(ZZ, prec)

%o return P((1+2*x^4)/((1-x^3)*(1-x-x^2))).list()

%o A081410_list(30) # _G. C. Greubel_, Aug 15 2019

%o (GAP) a:=[1,1,2,4,8];; for n in [6..40] do a[n]:=a[n-1]+a[n-2]+a[n-3] -a[n-4]-a[n-5]; od; a; # _G. C. Greubel_, Aug 15 2019

%Y Cf. A004695.

%K nonn

%O 1,3

%A _Benoit Cloitre_, Apr 20 2003