Cody

Problem 5. Triangle Numbers

Solution 3381973

Submitted on 25 Oct 2020 by Knox Peterson
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))

e = 0 e = 1 t = 1

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

e = 0 e = 1 e = 3 e = 6 t = 6

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

e = 0 e = 1 e = 3 e = 6 e = 10 e = 15 t = 15

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

e = 0 e = 1 e = 3 e = 6 e = 10 e = 15 e = 21 e = 28 e = 36 e = 45 e = 55 e = 66 e = 78 e = 91 e = 105 e = 120 e = 136 e = 153 e = 171 e = 190 e = 210 e = 231 e = 253 e = 276 e = 300 e = 325 e = 351 e = 378 e = 406 e = 435 e = 465 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!