login

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”).

Number of sequences with terms 1, 2 or 3 summing to n with no three consecutive 1's.
1

%I #9 Sep 08 2022 08:45:28

%S 1,1,2,3,6,10,17,30,52,90,156,271,470,815,1414,2453,4255,7381,12804,

%T 22211,38529,66836,115940,201120,348881,605201,1049837,1821143,

%U 3159121,5480100,9506282,16490465,28605867,49622350,86079461,149321296

%N Number of sequences with terms 1, 2 or 3 summing to n with no three consecutive 1's.

%H G. C. Greubel, <a href="/A123908/b123908.txt">Table of n, a(n) for n = 0..1000</a>

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

%F a(n) = a(n-2) + 2*a(n-3) + 2*a(n-4) + a(n-5).

%F G.f.: (1 + x + x^2)/(1 - x^2 - 2*x^3 - 2*x^4 - x^5). - _Chai Wah Wu_, May 28 2016

%e a(4) = 6 as 3 + 1, 1 + 3, 2 + 2, 1 + 1 + 2, 1 + 2 + 1 and 2 + 1 + 1 (but not 1 + 1 + 1 + 1).

%p a[0]:=1; a[1]:=1; a[2]:=2; a[3]:=3; a[4]:=6; for n from 5 to 45 do a[n] := a[n-2] +2*a[n-3] +2*a[n-4] +a[n-5] end do; seq(a[n], n = 0 .. 40); # modified by _G. C. Greubel_, Aug 06 2019

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

%t LinearRecurrence[{0,1,2,2,1}, {1,1,2,3,6}, 40] (* _G. C. Greubel_, Aug 06 2019 *)

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

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

%o (Sage) ((1+x+x^2)/(1-x^2-2*x^3-2*x^4-x^5)).series(x, 40).coefficients(x, sparse=False) # _G. C. Greubel_, Aug 06 2019

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

%K easy,nonn

%O 0,3

%A _Joel B. Lewis_, Oct 28 2006