OFFSET
0,3
COMMENTS
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
REFERENCES
Harold Abelson and Gerald Jay Sussman with Julie Sussman, Structure and Interpretation of Computer Programs, MIT Press, 1996.
LINKS
G. C. Greubel, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (1,2,3).
FORMULA
From R. J. Mathar, Aug 22 2008: (Start)
O.g.f.: x*(1+x)/(1-x-2*x^2-3*x^3).
MATHEMATICA
LinearRecurrence[{1, 2, 3}, {0, 1, 2}, 40] (* Harvey P. Dale, Mar 19 2023 *)
PROG
(Perl) perl -e '@a=(0, 1, 2); for(3..30){$a[$_]=$a[$_-1]+2*$a[$_-2]+3*$a[$_-3]; } print "@a "; '
(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
(SageMath)
@CachedFunction
def a(n): # a = A100550
if (n<3): return n
else: return a(n-1) + 2*a(n-2) + 3*a(n-3)
[a(n) for n in range(41)] # G. C. Greubel, Mar 27 2023
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
gamo (gamo(AT)telecable.es), Nov 27 2004
STATUS
approved