Cody

Problem 291. Triangle Numbers Below N

Solution 2498498

Submitted on 8 Jun 2020 by Ramesh Kumar V
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))

z1 = [] z = 1 z1 = 1 z = 3 z1 = 1 3 z = 6 z1 = 1 3 6 z = 10 z1 = 1 3 6 10 z = 15 z1 = 1 3 6 10 15 z = 21 z1 = 1 3 6 10 15 21 z = 28 z1 = 1 3 6 10 15 21 28 z = 36 z1 = 1 3 6 10 15 21 28 36 z = 45 z1 = 1 3 6 10 15 21 28 36 45 z = 55 z1 = 1 3 6 10 15 21 28 36 45 55 z = 66 z1 = 1 3 6 10 15 21 28 36 45 55 66 z = 78 z1 = 1 3 6 10 15 21 28 36 45 55 66 78 z = 91 z1 = 1 3 6 10 15 21 28 36 45 55 66 78 91 z = 105 y = 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))

z1 = [] z = 1 z1 = 1 z = 3 z1 = 1 3 z = 6 z1 = 1 3 6 z = 10 z1 = 1 3 6 10 z = 15 z1 = 1 3 6 10 15 z = 21 z1 = 1 3 6 10 15 21 z = 28 z1 = 1 3 6 10 15 21 28 z = 36 z1 = 1 3 6 10 15 21 28 36 z = 45 z1 = 1 3 6 10 15 21 28 36 45 z = 55 z1 = 1 3 6 10 15 21 28 36 45 55 z = 66 z1 = 1 3 6 10 15 21 28 36 45 55 66 z = 78 z1 = 1 3 6 10 15 21 28 36 45 55 66 78 z = 91 z1 = 1 3 6 10 15 21 28 36 45 55 66 78 91 z = 105 z1 = 1 3 6 10 15 21 28 36 45 55 66 78 91 105 z = 120 z1 = 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 z = 136 z1 = 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 z = 153 z1 = 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 z = 171 z1 = 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 z = 190 z1 = 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 z = 210 z1 = 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 210 z = 231 z1 = 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 210 231 z = 253 z1 = 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 210 231 253 z = 276 z1 = 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 210 231 253 276 z = 300 z1 = 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 210 231 253 276 300 z = 325 z1 = 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 z = 351 z1 = 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 z = 378 z1 = 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 z = 406 z1 = 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 z = 435 z1 = 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 z = 465 z1 = 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 465 z = 496 z1 = Columns 1 through 30 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 465 Column 31 496 z = 528 z1 = Columns 1 through 30 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 465 Columns 31 through 32 496 528 z = 561 z1 = Columns 1 through 30 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 465 Columns 31 through 33 496 528 561 z = 595 z1 = Columns 1 through 30 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 465 Columns 31 through 34 496 528 561 595 z = 630 z1 = Columns 1 through 30 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 465 Columns 31 through 35 496 528 561 595 630 z = 666 z1 = Columns 1 through 30 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 465 Columns 31 through 36 496 528 561 595 630 666 z = 703 z1 = Columns 1 through 30 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 465 Columns 31 through 37 496 528 561 595 630 666 703 z = 741 z1 = Columns 1 through 30 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 465 Columns 31 through 38 496 528 561 595 630 666 703 741 z = 780 z1 = Columns 1 through 30 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 465 Columns 31 through 39 496 528 561 595 630 666 703 741 780 z = 820 z1 = Columns 1 through 30 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 465 Columns 31 through 40 496 528 561 595 630 666 703 741 780 820 z = 861 z1 = Columns 1 through 30 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 465 Columns 31 through 41 496 528 561 595 630 666 703 741 780 820 861 z = 903 z1 = Columns 1 through 30 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 465 Columns 31 through 42 496 528 561 595 630 666 703 741 780 820 861 903 z = 946 z1 = Columns 1 through 30 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 465 Columns 31 through 43 496 528 561 595 630 666 703 741 780 820 861 903 946 z = 990 z1 = Columns 1 through 30 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 465 Columns 31 through 44 496 528 561 595 630 666 703 741 780 820 861 903 946 990 z = 1035 y = Columns 1 through 30 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 465 Columns 31 through 44 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!