Cody

Problem 5. Triangle Numbers

Solution 2096855

Submitted on 17 Jan 2020 by Sam Fischer
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))

y = 1

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

y = 1 y = 3 y = 6

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

y = 1 y = 3 y = 6 y = 10 y = 15

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

y = 1 y = 3 y = 6 y = 10 y = 15 y = 21 y = 28 y = 36 y = 45 y = 55 y = 66 y = 78 y = 91 y = 105 y = 120 y = 136 y = 153 y = 171 y = 190 y = 210 y = 231 y = 253 y = 276 y = 300 y = 325 y = 351 y = 378 y = 406 y = 435 y = 465