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

3 Solutions

3 Solvers

Last Solution submitted on Jun 14, 2026

Last 200 Solutions

Solution Comments

Show comments
Loading...

Problem Recent Solvers3

Suggested Problems

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!