Test  Status  Code Input and Output 

1  Pass 
n = 1;
t = 1;
assert(isequal(triangle(n),t))
t =
0
t =
1

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

3  Pass 
n = 5;
t = 15;
assert(isequal(triangle(n),t))
t =
0
t =
1
t =
3
t =
6
t =
10
t =
15

4  Pass 
n = 30;
t = 465;
assert(isequal(triangle(n),t))
t =
0
t =
1
t =
3
t =
6
t =
10
t =
15
t =
21
t =
28
t =
36
t =
45
t =
55
t =
66
t =
78
t =
91
t =
105
t =
120
t =
136
t =
153
t =
171
t =
190
t =
210
t =
231
t =
253
t =
276
t =
300
t =
325
t =
351
t =
378
t =
406
t =
435
t =
465

2939 Solvers
How to find the position of an element in a vector without using the find function
2436 Solvers
Determine if a Given Number is a Triangle Number
311 Solvers
387 Solvers
Split a string into chunks of specified length
348 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!