%I #16 Mar 27 2023 13:28:39
%S 0,1,2,4,11,25,59,142,335,796,1892,4489,10661,25315,60104,142717,
%T 338870,804616,1910507,4536349,10771211,25575430,60726899,144191392,
%U 342371480,812934961,1930252097,4583236459,10882545536,25839774745,61354575194
%N a(n) = a(n-1) + 2*a(n-2) + 3*a(n-3), for n>3, otherwise a(n) = n.
%C A recursive and iterative algorithm for the computation of a(n) appear as Exercise 1.11 in the book Structure and Interpretation of Computer Programs. - Bas Kok (no(AT)spam.com), Jan 31 2008
%D Harold Abelson and Gerald Jay Sussman with Julie Sussman, Structure and Interpretation of Computer Programs, MIT Press, 1996.
%H G. C. Greubel, <a href="/A100550/b100550.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 (1,2,3).
%F From _R. J. Mathar_, Aug 22 2008: (Start)
%F O.g.f.: x*(1+x)/(1-x-2*x^2-3*x^3).
%F a(n) = A101822(n-1) + A101822(n-2). (End)
%t LinearRecurrence[{1,2,3},{0,1,2},40] (* _Harvey P. Dale_, Mar 19 2023 *)
%o (Perl) perl -e '@a=(0,1,2);for(3..30){$a[$_]=$a[$_-1]+2*$a[$_-2]+3*$a[$_-3];} print "@a ";'
%o (Magma) [n le 3 select n-1 else Self(n-1) +2*Self(n-2) +3*Self(n-3): n in [1..41]]; // _G. C. Greubel_, Mar 27 2023
%o (SageMath)
%o @CachedFunction
%o def a(n): # a = A100550
%o if (n<3): return n
%o else: return a(n-1) + 2*a(n-2) + 3*a(n-3)
%o [a(n) for n in range(41)] # _G. C. Greubel_, Mar 27 2023
%Y Cf. A092836, A092835, A100477, A101822.
%K easy,nonn
%O 0,3
%A gamo (gamo(AT)telecable.es), Nov 27 2004