Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #40 Feb 28 2023 12:07:15
%S 1,1,1,4,4,7,16,19,37,67,94,178,295,460,829,1345,2209,3832,6244,10459,
%T 17740,29191,49117,82411,136690,229762,383923,639832,1073209,1791601,
%U 2992705,5011228,8367508,13989343,23401192,39091867,65369221,109295443
%N Expansion of (1+x)/(1-x^2-3*x^3).
%H Vincenzo Librandi, <a href="/A238389/b238389.txt">Table of n, a(n) for n = 0..1000</a>
%H <a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (0,1,3).
%F a(0)=1, a(1)=1, a(2)=1; for n>2, a(n) = a(n-2) + 3*a(n-3).
%F a(2n) = Sum_{j=0}^{n/3} binomial(n-j,2j)*3^(2j) + Sum_{j=0}^{(n-2)/3} binomial(n-1-j,2j+1)*3^(2j+1).
%F a(2n+1) = Sum_{j=0}^{n/3} binomial(n-j,2j)*3^(2j) + Sum_{j=0}^{(n-1)/3} binomial(n-j,2j+1)*3^(2j+1).
%F a(n) = |A106855(n)| + |A106855(n-1)| . - _R. J. Mathar_, Mar 13 2014
%e a(3) = 3*a(0)+a(1) = 4; a(4) = 3*a(1)+a(2) = 4; a(5) = 3*a(2)+a(3) = 7.
%p a:= n-> (<<0|1|0>, <0|0|1>, <3|1|0>>^n.<<(1$3)>>)[(1$2)]:
%p seq(a(n), n=0..44); # _Alois P. Heinz_, May 09 2021
%t (* First program *)
%t For[j=0, j<3, j++, a[j] = 1]
%t For[j=3, j<51, j++, a[j] = 3a[j-3] + a[j-2]]
%t Table[a[j], {j, 0, 50}]
%t (* Second program *)
%t CoefficientList[Series[(1+x)/(1-x^2-3x^3), {x, 0, 40}], x] (* _Vincenzo Librandi_, Mar 16 2014 *)
%t LinearRecurrence[{0,1,3},{1,1,1},40] (* _Harvey P. Dale_, Feb 28 2023 *)
%o (PARI) Vec((1+x)/(1-x^2-3*x^3)+O(x^99)) \\ _Charles R Greathouse IV_, Mar 06 2014
%o (Magma) [n le 3 select 1 else Self(n-2) +3*Self(n-3): n in [1..41]]; // _G. C. Greubel_, May 09 2021
%o (Sage)
%o def A238389_list(prec):
%o P.<x> = PowerSeriesRing(ZZ, prec)
%o return P( (1+x)/(1-x^2-3*x^3) ).list()
%o A238389_list(40) # _G. C. Greubel_, May 09 2021
%Y Cf. A006190, A134816, A159284, A213713.
%K nonn,easy
%O 0,4
%A _Sergio Falcon_, Feb 26 2014
%E Terms corrected by _Charles R Greathouse IV_, Mar 06 2014