Cody

# Problem 291. Triangle Numbers Below N

Solution 112104

Submitted on 13 Jul 2012 by Noah
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 = Columns 1 through 5 1 3 6 10 15 Columns 6 through 10 21 28 36 45 55 Columns 11 through 15 66 78 91 105 120 Columns 16 through 20 136 153 171 190 210 Columns 21 through 25 231 253 276 300 325 Columns 26 through 30 351 378 406 435 465 Columns 31 through 35 496 528 561 595 630 Columns 36 through 40 666 703 741 780 820 Columns 41 through 45 861 903 946 990 1035 Columns 46 through 50 1081 1128 1176 1225 1275 Columns 51 through 55 1326 1378 1431 1485 1540 Columns 56 through 60 1596 1653 1711 1770 1830 Columns 61 through 65 1891 1953 2016 2080 2145 Columns 66 through 70 2211 2278 2346 2415 2485 Columns 71 through 75 2556 2628 2701 2775 2850 Columns 76 through 80 2926 3003 3081 3160 3240 Columns 81 through 85 3321 3403 3486 3570 3655 Columns 86 through 90 3741 3828 3916 4005 4095 Columns 91 through 95 4186 4278 4371 4465 4560 Columns 96 through 100 4656 4753 4851 4950 5050 ans = Columns 1 through 10 1 3 6 10 15 21 28 36 45 55 Columns 11 through 13 66 78 91 ```

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

``` y = Columns 1 through 5 1 3 6 10 15 Columns 6 through 10 21 28 36 45 55 Columns 11 through 15 66 78 91 105 120 Columns 16 through 20 136 153 171 190 210 Columns 21 through 25 231 253 276 300 325 Columns 26 through 30 351 378 406 435 465 Columns 31 through 35 496 528 561 595 630 Columns 36 through 40 666 703 741 780 820 Columns 41 through 45 861 903 946 990 1035 Columns 46 through 50 1081 1128 1176 1225 1275 Columns 51 through 55 1326 1378 1431 1485 1540 Columns 56 through 60 1596 1653 1711 1770 1830 Columns 61 through 65 1891 1953 2016 2080 2145 Columns 66 through 70 2211 2278 2346 2415 2485 Columns 71 through 75 2556 2628 2701 2775 2850 Columns 76 through 80 2926 3003 3081 3160 3240 Columns 81 through 85 3321 3403 3486 3570 3655 Columns 86 through 90 3741 3828 3916 4005 4095 Columns 91 through 95 4186 4278 4371 4465 4560 Columns 96 through 100 4656 4753 4851 4950 5050 Columns 101 through 105 5151 5253 5356 5460 5565 Columns 106 through 110 5671 5778 5886 5995 6105 Columns 111 through 115 6216 6328 6441 6555 6670 Columns 116 through 120 6786 6903 7021 7140 7260 Columns 121 through 125 7381 7503 7626 7750 7875 Columns 126 through 130 8001 8128 8256 8385 8515 Columns 131 through 135 8646 8778 8911 9045 9180 Columns 136 through 140 9316 9453 9591 9730 9870 Columns 141 through 145 10011 10153 10296 10440 10585 Columns 146 through 150 10731 10878 11026 11175 11325 Columns 151 through 155 11476 11628 11781 11935 12090 Columns 156 through 160 12246 12403 12561 12720 12880 Columns 161 through 165 13041 13203 13366 13530 13695 Columns 166 through 170 13861 14028 14196 14365 14535 Columns 171 through 175 14706 14878 15051 15225 15400 Columns 176 through 180 15576 15753 15931 16110 16290 Columns 181 through 185 16471 16653 16836 17020 17205 Columns 186 through 190 17391 17578 17766 17955 18145 Columns 191 through 195 18336 18528 18721 18915 19110 Columns 196 through 200 19306 19503 19701 19900 20100 Columns 201 through 205 20301 20503 20706 20910 21115 Columns 206 through 210 21321 21528 21736 21945 22155 Columns 211 through 215 22366 22578 22791 23005 23220 Columns 216 through 220 23436 23653 23871 24090 24310 Columns 221 through 225 24531 24753 24976 25200 25425 Columns 226 through 230 25651 25878 26106 26335 26565 Columns 231 through 235 26796 27028 27261 27495 27730 Columns 236 through 240 27966 28203 28441 28680 28920 Columns 241 through 245 29161 29403 29646 29890 30135 Columns 246 through 250 30381 30628 30876 31125 31375 Columns 251 through 255 31626 31878 32131 32385 32640 Columns 256 through 260 32896 33153 33411 33670 33930 Columns 261 through 265 34191 34453 34716 34980 35245 Columns 266 through 270 35511 35778 36046 36315 36585 Columns 271 through 275 36856 37128 37401 37675 37950 Columns 276 through 280 38226 38503 38781 39060 39340 Columns 281 through 285 39621 39903 40186 40470 40755 Columns 286 through 290 41041 41328 41616 41905 42195 Columns 291 through 295 42486 42778 43071 43365 43660 Columns 296 through 300 43956 44253 44551 44850 45150 Columns 301 through 305 45451 45753 46056 46360 46665 Columns 306 through 310 46971 47278 47586 47895 48205 Columns 311 through 315 48516 48828 49141 49455 49770 Columns 316 through 320 50086 50403 50721 51040 51360 Columns 321 through 325 51681 52003 52326 52650 52975 Columns 326 through 330 53301 53628 53956 54285 54615 Columns 331 through 335 54946 55278 55611 55945 56280 Columns 336 through 340 56616 56953 57291 57630 57970 Columns 341 through 345 58311 58653 58996 59340 59685 Columns 346 through 350 60031 60378 60726 61075 61425 Columns 351 through 355 61776 62128 62481 62835 63190 Columns 356 through 360 63546 63903 64261 64620 64980 Columns 361 through 365 65341 65703 66066 66430 66795 Columns 366 through 370 67161 67528 67896 68265 68635 Columns 371 through 375 69006 69378 69751 70125 70500 Columns 376 through 380 70876 71253 71631 72010 72390 Columns 381 through 385 72771 73153 73536 73920 74305 Columns 386 through 390 74691 75078 75466 75855 76245 Columns 391 through 395 76636 77028 77421 77815 78210 Columns 396 through 400 78606 79003 79401 79800 80200 Columns 401 through 405 80601 81003 81406 81810 82215 Columns 406 through 410 82621 83028 83436 83845 84255 Columns 411 through 415 84666 85078 85491 85905 86320 Columns 416 through 420 86736 87153 87571 87990 88410 Columns 421 through 425 88831 89253 89676 90100 90525 Columns 426 through 430 90951 91378 91806 92235 92665 Columns 431 through 435 93096 93528 93961 94395 94830 Columns 436 through 440 95266 95703 96141 96580 97020 Columns 441 through 445 97461 97903 98346 98790 99235 Columns 446 through 450 99681 100128 100576 101025 101475 Columns 451 through 455 101926 102378 102831 103285 103740 Columns 456 through 460 104196 104653 105111 105570 106030 Columns 461 through 465 106491 106953 107416 107880 108345 Columns 466 through 470 108811 109278 109746 110215 110685 Columns 471 through 475 111156 111628 112101 112575 113050 Columns 476 through 480 113526 114003 114481 114960 115440 Columns 481 through 485 115921 116403 116886 117370 117855 Columns 486 through 490 118341 118828 119316 119805 120295 Columns 491 through 495 120786 121278 121771 122265 122760 Columns 496 through 500 123256 123753 124251 124750 125250 Columns 501 through 505 125751 126253 126756 127260 127765 Columns 506 through 510 128271 128778 129286 129795 130305 Columns 511 through 515 130816 131328 131841 132355 132870 Columns 516 through 520 133386 133903 134421 134940 135460 Columns 521 through 525 135981 136503 137026 137550 138075 Columns 526 through 530 138601 139128 139656 140185 140715 Columns 531 through 535 141246 141778 142311 142845 143380 Columns 536 through 540 143916 144453 144991 145530 146070 Columns 541 through 545 146611 147153 147696 148240 148785 Columns 546 through 550 149331 149878 150426 150975 151525 Columns 551 through 555 152076 152628 153181 153735 154290 Columns 556 through 560 154846 155403 155961 156520 157080 Columns 561 through 565 157641 158203 158766 159330 159895 Columns 566 through 570 160461 161028 161596 162165 162735 Columns 571 through 575 163306 163878 164451 165025 165600 Columns 576 through 580 ...```