Forum Discussion
Viz
Jan 05, 2021Brass Contributor
Lambda Example: Generate Fibonacci series
In this post, I would like to explain how I have used Lambda to create a function to generate a Fibonacci series array. This example can also be used to understand how to create an array where th...
Pancras
Oct 22, 2023Copper Contributor
Hi Viz,
Thank you so much for this angle. Excel has now the take and expand and omitted functions. answer is much easier now:
function name: Fibonachi
=LAMBDA(StopIter;[PreviousSequence];
LET(
PreviousSequence; IF(ISOMITTED(PreviousSequence); {1; 2}; PreviousSequence);
RowsPreviousSequence; ROWS(PreviousSequence);
CurrentSequence; EXPAND(
PreviousSequence;
RowsPreviousSequence + 1;
;
SUM(TAKE(PreviousSequence; -2))
);
IF(RowsPreviousSequence < StopIter; Fibonachi(StopIter; CurrentSequence); PreviousSequence)
)
)
call this like a1=Fibonachi(251)
Thank you so much for this angle. Excel has now the take and expand and omitted functions. answer is much easier now:
function name: Fibonachi
=LAMBDA(StopIter;[PreviousSequence];
LET(
PreviousSequence; IF(ISOMITTED(PreviousSequence); {1; 2}; PreviousSequence);
RowsPreviousSequence; ROWS(PreviousSequence);
CurrentSequence; EXPAND(
PreviousSequence;
RowsPreviousSequence + 1;
;
SUM(TAKE(PreviousSequence; -2))
);
IF(RowsPreviousSequence < StopIter; Fibonachi(StopIter; CurrentSequence); PreviousSequence)
)
)
call this like a1=Fibonachi(251)