Cody

Problem 45254. Tribonacci Sequence

Solution 2090487

Submitted on 13 Jan 2020 by Martin C.
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))

v = 0 0 1 v = 0 0 1 1 v = 0 0 1 1 2 t = 0 0 1 1 2

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

v = 0 0 1 v = 0 0 1 1 v = 0 0 1 1 2 v = 0 0 1 1 2 4 v = 0 0 1 1 2 4 7 v = 0 0 1 1 2 4 7 13 v = 0 0 1 1 2 4 7 13 24 v = 0 0 1 1 2 4 7 13 24 44 v = 0 0 1 1 2 4 7 13 24 44 81 t = 0 0 1 1 2 4 7 13 24 44 81

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))

v = 0 0 1 v = 0 0 1 1 v = 0 0 1 1 2 v = 0 0 1 1 2 4 v = 0 0 1 1 2 4 7 v = 0 0 1 1 2 4 7 13 v = 0 0 1 1 2 4 7 13 24 v = 0 0 1 1 2 4 7 13 24 44 v = 0 0 1 1 2 4 7 13 24 44 81 v = 0 0 1 1 2 4 7 13 24 44 81 149 v = 0 0 1 1 2 4 7 13 24 44 81 149 274 v = 0 0 1 1 2 4 7 13 24 44 81 149 274 504 v = 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 v = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Column 16 1705 v = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Columns 16 through 17 1705 3136 v = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Columns 16 through 18 1705 3136 5768 v = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Columns 16 through 19 1705 3136 5768 10609 v = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Columns 16 through 20 1705 3136 5768 10609 19513 v = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Columns 16 through 21 1705 3136 5768 10609 19513 35890 t = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Columns 16 through 21 1705 3136 5768 10609 19513 35890

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))

v = 0 0 1 v = 0 0 1 1 v = 0 0 1 1 2 v = 0 0 1 1 2 4 v = 0 0 1 1 2 4 7 v = 0 0 1 1 2 4 7 13 v = 0 0 1 1 2 4 7 13 24 v = 0 0 1 1 2 4 7 13 24 44 v = 0 0 1 1 2 4 7 13 24 44 81 v = 0 0 1 1 2 4 7 13 24 44 81 149 v = 0 0 1 1 2 4 7 13 24 44 81 149 274 v = 0 0 1 1 2 4 7 13 24 44 81 149 274 504 v = 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 v = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Column 16 1705 v = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Columns 16 through 17 1705 3136 v = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Columns 16 through 18 1705 3136 5768 v = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Columns 16 through 19 1705 3136 5768 10609 v = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Columns 16 through 20 1705 3136 5768 10609 19513 v = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Columns 16 through 21 1705 3136 5768 10609 19513 35890 v = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Columns 16 through 22 1705 3136 5768 10609 19513 35890 66012 v = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Columns 16 through 23 1705 3136 5768 10609 19513 35890 66012 121415 v = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Columns 16 through 24 1705 3136 5768 10609 19513 35890 66012 121415 223317 v = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Columns 16 through 25 1705 3136 5768 10609 19513 35890 66012 121415 223317 410744 v = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Columns 16 through 26 1705 3136 5768 10609 19513 35890 66012 121415 223317 410744 755476 v = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Columns 16 through 27 1705 3136 5768 10609 19513 35890 66012 121415 223317 410744 755476 1389537 v = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Columns 16 through 28 1705 3136 5768 10609 19513 35890 66012 121415 223317 410744 755476 1389537 2555757 v = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Columns 16 through 29 1705 3136 5768 10609 19513 35890 66012 121415 223317 410744 755476 1389537 2555757 4700770 v = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Columns 16 through 30 1705 3136 5768 10609 19513 35890 66012 121415 223317 410744 755476 1389537 2555757 4700770 8646064 t = Columns 1 through 15 0 0 1 1 2 4 7 13 24 44 81 149 274 504 927 Columns 16 through 30 1705 3136 5768 10609 19513 35890 66012 121415 223317 410744 755476 1389537 2555757 4700770 8646064

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!