Create a function that generates a sequence of length n based on the sum of the previous l terms.
- If l = 2, it acts like the Fibonacci sequence (starting with 0, 1).
- If l = 3, it acts like the Tribonacci sequence (starting with 0, 0, 1).
- If l = 4, it acts like the Tetranacci sequence (starting with 0, 0, 0, 1).
- If n <= 0, return an error: 'n must be greater than 0'.
- If l < 2, return an error: 'l must be at least 2'.
Solution Stats
Solution Comments
Show comments
Loading...
Problem Recent Solvers10
Suggested Problems
-
MATLAB 101: Multinacci Sequence Generator
10 Solvers
More from this Author30
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!