Cody

# Problem 291. Triangle Numbers Below N

Solution 1200195

Submitted on 29 May 2017 by Said BOUREZG
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
x = 100; y_correct = cumsum(1:13); assert(isequal(TriBeNum(x),y_correct))

ans = 2 sum = 3 ans = 3 sum = 6 ans = 4 sum = 10 ans = 5 sum = 15 ans = 6 sum = 21 ans = 7 sum = 28 ans = 8 sum = 36 ans = 9 sum = 45 ans = 10 sum = 55 ans = 11 sum = 66 ans = 12 sum = 78 ans = 13 sum = 91 ans = 14 sum = 105 ans = 1 3 6 10 15 21 28 36 45 55 66 78 91

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

ans = 2 sum = 3 ans = 3 sum = 6 ans = 4 sum = 10 ans = 5 sum = 15 ans = 6 sum = 21 ans = 7 sum = 28 ans = 8 sum = 36 ans = 9 sum = 45 ans = 10 sum = 55 ans = 11 sum = 66 ans = 12 sum = 78 ans = 13 sum = 91 ans = 14 sum = 105 ans = 15 sum = 120 ans = 16 sum = 136 ans = 17 sum = 153 ans = 18 sum = 171 ans = 19 sum = 190 ans = 20 sum = 210 ans = 21 sum = 231 ans = 22 sum = 253 ans = 23 sum = 276 ans = 24 sum = 300 ans = 25 sum = 325 ans = 26 sum = 351 ans = 27 sum = 378 ans = 28 sum = 406 ans = 29 sum = 435 ans = 30 sum = 465 ans = 31 sum = 496 ans = 32 sum = 528 ans = 33 sum = 561 ans = 34 sum = 595 ans = 35 sum = 630 ans = 36 sum = 666 ans = 37 sum = 703 ans = 38 sum = 741 ans = 39 sum = 780 ans = 40 sum = 820 ans = 41 sum = 861 ans = 42 sum = 903 ans = 43 sum = 946 ans = 44 sum = 990 ans = 45 sum = 1035 ans = 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

### Community Treasure Hunt

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

Start Hunting!