Cody

Problem 5. Triangle Numbers

Solution 2192931

Submitted on 5 Apr 2020 by drummer
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 = 1; t = 1; assert(isequal(triangle(n),t))

idx = 1 t = 1

2   Pass
n = 3; t = 6; assert(isequal(triangle(n),t))

idx = 1 t = 1 idx = 2 t = 3 idx = 3 t = 6

3   Pass
n = 5; t = 15; assert(isequal(triangle(n),t))

idx = 1 t = 1 idx = 2 t = 3 idx = 3 t = 6 idx = 4 t = 10 idx = 5 t = 15

4   Pass
n = 30; t = 465; assert(isequal(triangle(n),t))

idx = 1 t = 1 idx = 2 t = 3 idx = 3 t = 6 idx = 4 t = 10 idx = 5 t = 15 idx = 6 t = 21 idx = 7 t = 28 idx = 8 t = 36 idx = 9 t = 45 idx = 10 t = 55 idx = 11 t = 66 idx = 12 t = 78 idx = 13 t = 91 idx = 14 t = 105 idx = 15 t = 120 idx = 16 t = 136 idx = 17 t = 153 idx = 18 t = 171 idx = 19 t = 190 idx = 20 t = 210 idx = 21 t = 231 idx = 22 t = 253 idx = 23 t = 276 idx = 24 t = 300 idx = 25 t = 325 idx = 26 t = 351 idx = 27 t = 378 idx = 28 t = 406 idx = 29 t = 435 idx = 30 t = 465

Suggested Problems

More from this Author95

Community Treasure Hunt

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

Start Hunting!