Cody

Problem 291. Triangle Numbers Below N

Solution 3278273

Submitted on 19 Oct 2020
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   Fail
x = 100; y_correct = cumsum(1:13); assert(isequal(TriBeNum(x),y_correct))

y = Columns 1 through 29 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 210 231 253 276 300 325 351 378 406 435 Columns 30 through 44 465 496 528 561 595 630 666 703 741 780 820 861 903 946 990

Assertion failed.

2   Pass
x = 1000; y_correct = cumsum(1:44); assert(isequal(TriBeNum(x),y_correct))

y = Columns 1 through 29 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 210 231 253 276 300 325 351 378 406 435 Columns 30 through 44 465 496 528 561 595 630 666 703 741 780 820 861 903 946 990

Suggested Problems

More from this Author56

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!