RosettaCodeData/Task/Leonardo-numbers/Maxima/leonardo-numbers.maxima
2023-09-01 09:35:06 -07:00

11 lines
427 B
Text

/* Function that return the terms of an specified Leonardo sequence */
leo_specified(n,L0,L1,add):=block(
if n=0 then L[n]:L0 else if n=1 then L[n]:L1 else L[n]:L[n-1]+L[n-2]+add,
L[n])$
/* Test cases */
/* First 25 terms of Leonardo numbers (specification (1,1,1)) */
makelist(leo_specified(i,1,1,1),i,0,25);
/* First 25 terms of Fibonacci numbers (specification (0,1,0)) */
makelist(leo_specified(i,0,1,0),i,0,25);