Cody

Problem 5. Triangle Numbers

Solution 540012

Submitted on 4 Dec 2014 by Stephen
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))

b = 1 add = 0 add = 1 t = 1

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

b = 1 2 3 add = 0 add = 1 add = 3 add = 6 t = 6

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

b = 1 2 3 4 5 add = 0 add = 1 add = 3 add = 6 add = 10 add = 15 t = 15

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

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

Suggested Problems

More from this Author95