Cody

Problem 291. Triangle Numbers Below N

Solution 817475

Submitted on 1 Feb 2016 by William
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))

y = 1 3 y = 1 3 6 y = 1 3 6 10 y = 1 3 6 10 15 y = 1 3 6 10 15 21 y = 1 3 6 10 15 21 28 y = 1 3 6 10 15 21 28 36 y = 1 3 6 10 15 21 28 36 45 y = 1 3 6 10 15 21 28 36 45 55 y = 1 3 6 10 15 21 28 36 45 55 66 y = 1 3 6 10 15 21 28 36 45 55 66 78 y = 1 3 6 10 15 21 28 36 45 55 66 78 91 y = 1 3 6 10 15 21 28 36 45 55 66 78 91 105

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

y = 1 3 y = 1 3 6 y = 1 3 6 10 y = 1 3 6 10 15 y = 1 3 6 10 15 21 y = 1 3 6 10 15 21 28 y = 1 3 6 10 15 21 28 36 y = 1 3 6 10 15 21 28 36 45 y = 1 3 6 10 15 21 28 36 45 55 y = 1 3 6 10 15 21 28 36 45 55 66 y = 1 3 6 10 15 21 28 36 45 55 66 78 y = 1 3 6 10 15 21 28 36 45 55 66 78 91 y = 1 3 6 10 15 21 28 36 45 55 66 78 91 105 y = 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 y = 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Column 17 153 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 18 153 171 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 19 153 171 190 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 20 153 171 190 210 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 21 153 171 190 210 231 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 22 153 171 190 210 231 253 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 23 153 171 190 210 231 253 276 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 24 153 171 190 210 231 253 276 300 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 25 153 171 190 210 231 253 276 300 325 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 26 153 171 190 210 231 253 276 300 325 351 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 27 153 171 190 210 231 253 276 300 325 351 378 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 28 153 171 190 210 231 253 276 300 325 351 378 406 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 29 153 171 190 210 231 253 276 300 325 351 378 406 435 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 30 153 171 190 210 231 253 276 300 325 351 378 406 435 465 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 31 153 171 190 210 231 253 276 300 325 351 378 406 435 465 496 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 32 153 171 190 210 231 253 276 300 325 351 378 406 435 465 496 528 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 32 153 171 190 210 231 253 276 300 325 351 378 406 435 465 496 528 Column 33 561 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 32 153 171 190 210 231 253 276 300 325 351 378 406 435 465 496 528 Columns 33 through 34 561 595 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 32 153 171 190 210 231 253 276 300 325 351 378 406 435 465 496 528 Columns 33 through 35 561 595 630 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 32 153 171 190 210 231 253 276 300 325 351 378 406 435 465 496 528 Columns 33 through 36 561 595 630 666 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 32 153 171 190 210 231 253 276 300 325 351 378 406 435 465 496 528 Columns 33 through 37 561 595 630 666 703 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 32 153 171 190 210 231 253 276 300 325 351 378 406 435 465 496 528 Columns 33 through 38 561 595 630 666 703 741 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 32 153 171 190 210 231 253 276 300 325 351 378 406 435 465 496 528 Columns 33 through 39 561 595 630 666 703 741 780 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 32 153 171 190 210 231 253 276 300 325 351 378 406 435 465 496 528 Columns 33 through 40 561 595 630 666 703 741 780 820 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 32 153 171 190 210 231 253 276 300 325 351 378 406 435 465 496 528 Columns 33 through 41 561 595 630 666 703 741 780 820 861 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 32 153 171 190 210 231 253 276 300 325 351 378 406 435 465 496 528 Columns 33 through 42 561 595 630 666 703 741 780 820 861 903 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 32 153 171 190 210 231 253 276 300 325 351 378 406 435 465 496 528 Columns 33 through 43 561 595 630 666 703 741 780 820 861 903 946 y = Columns 1 through 16 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 Columns 17 through 32 153 171 190 210 231 253 276 300 325 351 378 406 435 465 496 528 Columns 33 through 44 561 595 630 666 703 741 780 820 861 903 946 990 y = Columns 1 through 8 1 3 6 10 15 21 28 36 Columns 9 through 16 45 55 66 78 91 105 120 136 Columns 17 through 24 153 171 190 210 231 253 276 300 Columns 25 through 32 325 351 378 406 435 465 496 528 Columns 33 through 40 561 595 630 666 703 741 780 820 Columns 41 through 45 861 903 946 990 1035

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!