Cody

# Problem 5. Triangle Numbers

Solution 192354

Submitted on 17 Jan 2013 by Ruth
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 t = 1

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

y = 3 y = 3 2 y = 3 2 1 t = 6

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

y = 5 y = 5 4 y = 5 4 3 y = 5 4 3 2 y = 5 4 3 2 1 t = 15

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

y = 30 y = 30 29 y = 30 29 28 y = 30 29 28 27 y = 30 29 28 27 26 y = 30 29 28 27 26 25 y = 30 29 28 27 26 25 24 y = 30 29 28 27 26 25 24 23 y = 30 29 28 27 26 25 24 23 22 y = 30 29 28 27 26 25 24 23 22 21 y = 30 29 28 27 26 25 24 23 22 21 20 y = 30 29 28 27 26 25 24 23 22 21 20 19 y = 30 29 28 27 26 25 24 23 22 21 20 19 18 y = 30 29 28 27 26 25 24 23 22 21 20 19 18 17 y = 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 y = 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 y = Columns 1 through 16 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 Column 17 14 y = Columns 1 through 16 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 Columns 17 through 18 14 13 y = Columns 1 through 16 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 Columns 17 through 19 14 13 12 y = Columns 1 through 16 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 Columns 17 through 20 14 13 12 11 y = Columns 1 through 16 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 Columns 17 through 21 14 13 12 11 10 y = Columns 1 through 16 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 Columns 17 through 22 14 13 12 11 10 9 y = Columns 1 through 16 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 Columns 17 through 23 14 13 12 11 10 9 8 y = Columns 1 through 16 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 Columns 17 through 24 14 13 12 11 10 9 8 7 y = Columns 1 through 16 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 Columns 17 through 25 14 13 12 11 10 9 8 7 6 y = Columns 1 through 16 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 Columns 17 through 26 14 13 12 11 10 9 8 7 6 5 y = Columns 1 through 16 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 Columns 17 through 27 14 13 12 11 10 9 8 7 6 5 4 y = Columns 1 through 16 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 Columns 17 through 28 14 13 12 11 10 9 8 7 6 5 4 3 y = Columns 1 through 16 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 Columns 17 through 29 14 13 12 11 10 9 8 7 6 5 4 3 2 y = Columns 1 through 16 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 Columns 17 through 30 14 13 12 11 10 9 8 7 6 5 4 3 2 1 t = 465