Cody

# Problem 5. Triangle Numbers

Solution 2165706

Submitted on 19 Mar 2020 by Lucía Honrubia Fernández
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))

sum = 1 i = 2 t = 1

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

sum = 1 i = 2 sum = 3 i = 3 sum = 6 i = 4 t = 6

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

sum = 1 i = 2 sum = 3 i = 3 sum = 6 i = 4 sum = 10 i = 5 sum = 15 i = 6 t = 15

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

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

### Community Treasure Hunt

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

Start Hunting!