Cody

Problem 5. Triangle Numbers

Solution 1283055

Submitted on 8 Oct 2017 by ddd ppp
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))

t = 0 a = 1 t = 1

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

t = 0 a = 1 t = 1 a = 2 t = 3 a = 3 t = 6

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

t = 0 a = 1 t = 1 a = 2 t = 3 a = 3 t = 6 a = 4 t = 10 a = 5 t = 15

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

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