Generate Tribonacci Sequence - MATLAB Cody - MATLAB Central

Problem 55985. Generate Tribonacci Sequence

Difficulty:Rate
The "Tribonacci" sequence is an extension of the idea of the Fibonacci sequence:
That is, each new term is the sum of the three previous terms.
If the sequence starts with 0, 1, 1, the first 10 Tribonacci numbers are: 0, 1, 1, 2, 4, 7, 13, 24, 44, 81.
If the sequence instead starts with 2, 3, 7, the first 15 Tribonacci numbers are: 2, 3, 7, 12, 22, 41, 75, 138, 254, 467, 859, 1580, 2906, 5345, 9831.
Given a vector of three numbers, Tstart, and an integer n (> 3), return an n-element row vector of the first n Tribonacci numbers starting with Tstart.
T = tribo([2 3 7],15)
T =
2 3 7 12 22 41 75 138 254 467 859 1580 2906 5345 9831

Solution Stats

63.09% Correct | 36.91% Incorrect
Last Solution submitted on Nov 08, 2025

Problem Comments

Solution Comments

Show comments
Join Cody Contest 2025 — Have Fun and Win Prizes!
...
We’re excited to invite you to Cody Contest 2025! 🎉 Pick a team,...
🚀 MATLAB EXPO 2025 – Day 2 Starts Tomorrow, November 13!
Don’t miss out on two incredible keynotes that will shape the future...
0

Problem Recent Solvers175

Suggested Problems

More from this Author12

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!