login
a(n) = 3*a(n-1) + 2*a(n-2) + a(n-3) if n>=3, otherwise a(n) = n.
3

%I #29 Aug 25 2023 12:18:45

%S 0,1,2,8,29,105,381,1382,5013,18184,65960,239261,867887,3148143,

%T 11419464,41422565,150254766,545028892,1977018773,7171368869,

%U 26013173045,94359275646,342275541897,1241558350028,4503585409524

%N a(n) = 3*a(n-1) + 2*a(n-2) + a(n-3) if n>=3, otherwise a(n) = n.

%C Weighted sum of the three previous terms.

%C a(n+1) is the number of ways to tile a strip of length n with 3 colors of squares, 2 colors of dominos, and 1 color of tromino, with the restriction that if the first tile is a square, then it can only use two colors. - _Greg Dresden_ and Bora Bursali, Aug 17 2023

%H G. C. Greubel, <a href="/A100477/b100477.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 (3,2,1).

%F From _R. J. Mathar_, Aug 22 2008: (Start)

%F O.g.f.: x*(1-x)/(1-3*x-2*x^2-x^3).

%F a(n) = A108153(n) - A108153(n-1). (End)

%F a(0)=0, a(1)=1, a(2)=2, a(n)=3*a(n-1)+2*a(n-2)+a(n-3). - _Harvey P. Dale_, Jun 19 2015

%t RecurrenceTable[{a[n]== 3a[n-1] +2a[n-2] +a[n-3], a[0]==0, a[1]==1, a[2]==2}, a, {n,0,26}] (* or *)

%t CoefficientList[ Series[(x^2-x)/(x^3+2x^2+3x-1), {x,0,26}], x] (* _Robert G. Wilson v_, May 19 2015 *)

%t LinearRecurrence[{3,2,1},{0,1,2},40] (* _Harvey P. Dale_, Jun 19 2015 *)

%o (Perl) #!/usr/local/bin/perl -w $d=0; $c=1; $b=2; print "$d,$c,$b,"; $a=0; for (;;){ $a=3*$b+2*$c+$d; $d=$c; $c=$b; $b=$a; print "$a,"; last if ($a >2**61); } __END__

%o (Magma) [n le 3 select n-1 else 3*Self(n-1)+2*Self(n-2)+Self(n-3): n in [1..30]]; // _Vincenzo Librandi_, May 20 2015

%o (SageMath)

%o @CachedFunction

%o def a(n): # a = A100477

%o if (n<3): return n

%o else: return 3*a(n-1)+2*a(n-2)+a(n-3)

%o [a(n) for n in range(41)] # _G. C. Greubel_, Apr 06 2023

%Y Cf. A108153.

%K nonn,easy

%O 0,3

%A gamo (gamo(AT)telecable.es), Nov 22 2004