Cody

# Problem 291. Triangle Numbers Below N

Solution 173328

Submitted on 5 Dec 2012 by Evan
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 = 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 48 861 903 946 990 1035 1081 1128 1176 Columns 49 through 56 1225 1275 1326 1378 1431 1485 1540 1596 Columns 57 through 64 1653 1711 1770 1830 1891 1953 2016 2080 Columns 65 through 72 2145 2211 2278 2346 2415 2485 2556 2628 Columns 73 through 80 2701 2775 2850 2926 3003 3081 3160 3240 Columns 81 through 88 3321 3403 3486 3570 3655 3741 3828 3916 Columns 89 through 96 4005 4095 4186 4278 4371 4465 4560 4656 Columns 97 through 100 4753 4851 4950 5050 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 = 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 48 861 903 946 990 1035 1081 1128 1176 Columns 49 through 56 1225 1275 1326 1378 1431 1485 1540 1596 Columns 57 through 64 1653 1711 1770 1830 1891 1953 2016 2080 Columns 65 through 72 2145 2211 2278 2346 2415 2485 2556 2628 Columns 73 through 80 2701 2775 2850 2926 3003 3081 3160 3240 Columns 81 through 88 3321 3403 3486 3570 3655 3741 3828 3916 Columns 89 through 96 4005 4095 4186 4278 4371 4465 4560 4656 Columns 97 through 104 4753 4851 4950 5050 5151 5253 5356 5460 Columns 105 through 112 5565 5671 5778 5886 5995 6105 6216 6328 Columns 113 through 120 6441 6555 6670 6786 6903 7021 7140 7260 Columns 121 through 128 7381 7503 7626 7750 7875 8001 8128 8256 Columns 129 through 136 8385 8515 8646 8778 8911 9045 9180 9316 Columns 137 through 144 9453 9591 9730 9870 10011 10153 10296 10440 Columns 145 through 152 10585 10731 10878 11026 11175 11325 11476 11628 Columns 153 through 160 11781 11935 12090 12246 12403 12561 12720 12880 Columns 161 through 168 13041 13203 13366 13530 13695 13861 14028 14196 Columns 169 through 176 14365 14535 14706 14878 15051 15225 15400 15576 Columns 177 through 184 15753 15931 16110 16290 16471 16653 16836 17020 Columns 185 through 192 17205 17391 17578 17766 17955 18145 18336 18528 Columns 193 through 200 18721 18915 19110 19306 19503 19701 19900 20100 Columns 201 through 208 20301 20503 20706 20910 21115 21321 21528 21736 Columns 209 through 216 21945 22155 22366 22578 22791 23005 23220 23436 Columns 217 through 224 23653 23871 24090 24310 24531 24753 24976 25200 Columns 225 through 232 25425 25651 25878 26106 26335 26565 26796 27028 Columns 233 through 240 27261 27495 27730 27966 28203 28441 28680 28920 Columns 241 through 248 29161 29403 29646 29890 30135 30381 30628 30876 Columns 249 through 256 31125 31375 31626 31878 32131 32385 32640 32896 Columns 257 through 264 33153 33411 33670 33930 34191 34453 34716 34980 Columns 265 through 272 35245 35511 35778 36046 36315 36585 36856 37128 Columns 273 through 280 37401 37675 37950 38226 38503 38781 39060 39340 Columns 281 through 288 39621 39903 40186 40470 40755 41041 41328 41616 Columns 289 through 296 41905 42195 42486 42778 43071 43365 43660 43956 Columns 297 through 304 44253 44551 44850 45150 45451 45753 46056 46360 Columns 305 through 312 46665 46971 47278 47586 47895 48205 48516 48828 Columns 313 through 320 49141 49455 49770 50086 50403 50721 51040 51360 Columns 321 through 328 51681 52003 52326 52650 52975 53301 53628 53956 Columns 329 through 336 54285 54615 54946 55278 55611 55945 56280 56616 Columns 337 through 344 56953 57291 57630 57970 58311 58653 58996 59340 Columns 345 through 352 59685 60031 60378 60726 61075 61425 61776 62128 Columns 353 through 360 62481 62835 63190 63546 63903 64261 64620 64980 Columns 361 through 368 65341 65703 66066 66430 66795 67161 67528 67896 Columns 369 through 376 68265 68635 69006 69378 69751 70125 70500 70876 Columns 377 through 384 71253 71631 72010 72390 72771 73153 73536 73920 Columns 385 through 392 74305 74691 75078 75466 75855 76245 76636 77028 Columns 393 through 400 77421 77815 78210 78606 79003 79401 79800 80200 Columns 401 through 408 80601 81003 81406 81810 82215 82621 83028 83436 Columns 409 through 416 83845 84255 84666 85078 85491 85905 86320 86736 Columns 417 through 424 87153 87571 87990 88410 88831 89253 89676 90100 Columns 425 through 432 90525 90951 91378 91806 92235 92665 93096 93528 Columns 433 through 440 93961 94395 94830 95266 95703 96141 96580 97020 Columns 441 through 448 97461 97903 98346 98790 99235 99681 100128 100576 Columns 449 through 456 101025 101475 101926 102378 102831 103285 103740 104196 Columns 457 through 464 104653 105111 105570 106030 106491 106953 107416 107880 Columns 465 through 472 108345 108811 109278 109746 110215 110685 111156 111628 Columns 473 through 480 112101 112575 113050 113526 114003 114481 114960 115440 Columns 481 through 488 115921 116403 116886 117370 117855 118341 118828 119316 Columns 489 through 496 119805 120295 120786 121278 121771 122265 122760 123256 Columns 497 through 504 123753 124251 124750 125250 125751 126253 126756 127260 Columns 505 through 512 127765 128271 128778 129286 129795 130305 130816 131328 Columns 513 through 520 131841 132355 132870 133386 133903 134421 134940 135460 Columns 521 through 528 135981 136503 137026 137550 138075 138601 139128 139656 Columns 529 through 536 140185 140715 141246 141778 142311 142845 143380 143916 Columns 537 through 544 144453 144991 145530 146070 146611 147153 147696 148240 Columns 545 through 552 148785 149331 149878 150426 150975 151525 152076 152628 Columns 553 through 560 153181 153735 154290 154846 155403 155961 156520 157080 Columns 561 through 568 157641 158203 158766 159330 159895 160461 161028 161596 Columns 569 through 576 162165 162735 163306 163878 164451 165025 165600 166176 Columns 577 through 584 166753 167331 167910 168490 169071 169653 170236 170820 Columns 585 through 592 171405 171991 172578 173166 173755 174345 174936 175528 Columns 593 through 600 176121 176715 177310 177906 178503 179101 179700 180300 Columns 601 through 608 180901 181503 182106 182710 183315 183921 184528 185136 Columns 609 through 616 185745 186355 186966 187578 188191 188805 189420 190036 Columns 617 through 624 190653 191271 191890 192510 193131 193753 194376 195000 Columns 625 through 632 195625 196251 196878 197506 198135 198765 199396 200028 Columns 633 through 640 200661 201295 201930 202566 203203 203841 204480 205120 Columns 641 through 648 205761 206403 207046 207690 208335 208981 209628 210276 Columns 649 through 656 210925 211575 21...```