Cody

Problem 45254. Tribonacci Sequence

Solution 2881382

Submitted on 27 Aug 2020 by Alfonso Nieto-Castanon
  • Size: 27
  • This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
n = 5; y_correct = [0,0,1,1,2]; assert(isequal(tribonacci(n),y_correct))

2   Pass
n = 11; y_correct = [0 0 1 1 2 4 7 13 24 44 81 ]; assert(isequal(tribonacci(n),y_correct))

3   Pass
n = 21; y_correct = [0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 1705 3136 5768 10609 19513 35890]; assert(isequal(tribonacci(n),y_correct))

4   Pass
n = 30; y_correct =[ 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 1705 3136 5768 10609 19513 35890 66012 121415 223317 410744 755476 1389537 2555757 4700770 8646064]; assert(isequal(tribonacci(n),y_correct))

Suggested Problems

More from this Author149

Community Treasure Hunt

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

Start Hunting!