Cody

# Problem 44360. Pentagonal Numbers

Solution 1300554

Submitted on 19 Oct 2017 by Jakub Rysanek
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
x1 = 1; x2 = 25; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,[1,5,12,22])) assert(isequal(d,[0,1,0,0]))

val = 1 val = 5 val = 12 val = 22 val = 35 p = 1 5 12 22 d = 1×4 logical array 0 1 0 0

2   Pass
x1 = 1; x2 = 4; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,1)) assert(isequal(d,0))

val = 1 val = 5 p = 1 d = logical 0

3   Pass
x1 = 10; x2 = 40; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,[12,22,35])) assert(isequal(d,[0,0,1]))

val = 1 val = 5 val = 12 val = 22 val = 35 val = 51 p = 12 22 35 d = 1×3 logical array 0 0 1

4   Pass
x1 = 10; x2 = 99; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,[12,22,35,51,70,92])) assert(isequal(d,[0,0,1,0,1,0]))

val = 1 val = 5 val = 12 val = 22 val = 35 val = 51 val = 70 val = 92 val = 117 p = 12 22 35 51 70 92 d = 1×6 logical array 0 0 1 0 1 0

5   Pass
x1 = 100; x2 = 999; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,[117,145,176,210,247,287,330,376,425,477,532,590,651,715,782,852,925])) assert(isequal(d,[0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1]))

val = 1 val = 5 val = 12 val = 22 val = 35 val = 51 val = 70 val = 92 val = 117 val = 145 val = 176 val = 210 val = 247 val = 287 val = 330 val = 376 val = 425 val = 477 val = 532 val = 590 val = 651 val = 715 val = 782 val = 852 val = 925 val = 1001 p = 117 145 176 210 247 287 330 376 425 477 532 590 651 715 782 852 925 d = 1×17 logical array 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1

6   Pass
x1 = 40; x2 = 50; [p,d] = pentagonal_numbers(x1,x2) assert(isempty(p)) assert(isempty(d))

val = 1 val = 5 val = 12 val = 22 val = 35 val = 51 p = [] d = 0×0 empty logical array

7   Pass
x1 = 1000; x2 = 1500; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,[1001,1080,1162,1247,1335,1426])) assert(isequal(d,[0,1,0,0,1,0]))

val = 1 val = 5 val = 12 val = 22 val = 35 val = 51 val = 70 val = 92 val = 117 val = 145 val = 176 val = 210 val = 247 val = 287 val = 330 val = 376 val = 425 val = 477 val = 532 val = 590 val = 651 val = 715 val = 782 val = 852 val = 925 val = 1001 val = 1080 val = 1162 val = 1247 val = 1335 val = 1426 val = 1520 p = 1001 1080 1162 1247 1335 1426 d = 1×6 logical array 0 1 0 0 1 0

8   Pass
x1 = 1500; x2 = 3000; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,[1520,1617,1717,1820,1926,2035,2147,2262,2380,2501,2625,2752,2882])) assert(isequal(d,[1,0,0,1,0,1,0,0,1,0,1,0,0]))

val = 1 val = 5 val = 12 val = 22 val = 35 val = 51 val = 70 val = 92 val = 117 val = 145 val = 176 val = 210 val = 247 val = 287 val = 330 val = 376 val = 425 val = 477 val = 532 val = 590 val = 651 val = 715 val = 782 val = 852 val = 925 val = 1001 val = 1080 val = 1162 val = 1247 val = 1335 val = 1426 val = 1520 val = 1617 val = 1717 val = 1820 val = 1926 val = 2035 val = 2147 val = 2262 val = 2380 val = 2501 val = 2625 val = 2752 val = 2882 val = 3015 p = 1520 1617 1717 1820 1926 2035 2147 2262 2380 2501 2625 2752 2882 d = 1×13 logical array 1 0 0 1 0 1 0 0 1 0 1 0 0

9   Pass
x1 = 1; x2 = 3000; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,[1,5,12,22,35,51,70,92,117,145,176,210,247,287,330,376,425,477,532,590,651,715,782,852,925,1001,1080,1162,1247,1335,1426,1520,1617,1717,1820,1926,2035,2147,2262,2380,2501,2625,2752,2882])) assert(isequal(d,[0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0]))

val = 1 val = 5 val = 12 val = 22 val = 35 val = 51 val = 70 val = 92 val = 117 val = 145 val = 176 val = 210 val = 247 val = 287 val = 330 val = 376 val = 425 val = 477 val = 532 val = 590 val = 651 val = 715 val = 782 val = 852 val = 925 val = 1001 val = 1080 val = 1162 val = 1247 val = 1335 val = 1426 val = 1520 val = 1617 val = 1717 val = 1820 val = 1926 val = 2035 val = 2147 val = 2262 val = 2380 val = 2501 val = 2625 val = 2752 val = 2882 val = 3015 p = Columns 1 through 15 1 5 12 22 35 51 70 92 117 145 176 210 247 287 330 Columns 16 through 30 376 425 477 532 590 651 715 782 852 925 1001 1080 1162 1247 1335 Columns 31 through 44 1426 1520 1617 1717 1820 1926 2035 2147 2262 2380 2501 2625 2752 2882 d = 1×44 logical array 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0

10   Pass
x1 = 10000; x2 = 12000; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,[10045,10292,10542,10795,11051,11310,11572,11837])) assert(isequal(d,[1,0,0,1,0,1,0,0]))

val = 1 val = 5 val = 12 val = 22 val = 35 val = 51 val = 70 val = 92 val = 117 val = 145 val = 176 val = 210 val = 247 val = 287 val = 330 val = 376 val = 425 val = 477 val = 532 val = 590 val = 651 val = 715 val = 782 val = 852 val = 925 val = 1001 val = 1080 val = 1162 val = 1247 val = 1335 val = 1426 val = 1520 val = 1617 val = 1717 val = 1820 val = 1926 val = 2035 val = 2147 val = 2262 val = 2380 val = 2501 val = 2625 val = 2752 val = 2882 val = 3015 val = 3151 val = 3290 val = 3432 val = 3577 val = 3725 val = 3876 val = 4030 val = 4187 val = 4347 val = 4510 val = 4676 val = 4845 val = 5017 val = 5192 val = 5370 val = 5551 val = 5735 val = 5922 val = 6112 val = 6305 val = 6501 val = 6700 val = 6902 val = 7107 val = 7315 val = 7526 val = 7740 val = 7957 val = 8177 val = 8400 val = 8626 val = 8855 val = 9087 val = 9322 val = 9560 val = 9801 val = 10045 val = 10292 val = 10542 val = 10795 val = 11051 val = 11310 val = 11572 val = 11837 val = 12105 p = 10045 10292 10542 10795 11051 11310 11572 11837 d = 1×8 logical array 1 0 0 1 0 1 0 0

11   Pass
x1 = 100000; x2 = 110000; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,[100492,101270,102051,102835,103622,104412,105205,106001,106800,107602,108407,109215])) assert(isequal(d,[0,1,0,1,0,0,1,0,1,0,0,1]))

val = 1 val = 5 val = 12 val = 22 val = 35 val = 51 val = 70 val = 92 val = 117 val = 145 val = 176 val = 210 val = 247 val = 287 val = 330 val = 376 val = 425 val = 477 val = 532 val = 590 val = 651 val = 715 val = 782 val = 852 val = 925 val = 1001 val = 1080 val = 1162 val = 1247 val = 1335 val = 1426 val = 1520 val = 1617 val = 1717 val = 1820 val = 1926 val = 2035 val = 2147 val = 2262 val = 2380 val = 2501 val = 2625 val = 2752 val = 2882 val = 3015 val = 3151 val = 3290 val = 3432 val = 3577 val = 3725 val = 3876 val = 4030 val = 4187 val = 4347 val = 4510 val = 4676 val = 4845 val = 5017 val = 5192 val = 5370 val = 5551 val = 5735 val = 5922 val = 6112 val = 6305 val = 6501 val = 6700 val = 6902 val = 7107 val = 7315 val = 7526 val = 7740 val = 7957 val = 8177 val = 8400 val = 8626 val = 8855 val = 9087 val = 9322 val = 9560 val = 9801 val = 10045 val = 10292 val = 10542 val = 10795 val = 11051 val = 11310 val = 11572 val = 11837 val = 12105 val = 12376 val = 12650 val = 12927 val = 13207 val = 13490 val = 13776 val = 14065 val = 14357 val = 14652 val = 14950 val = 15251 val = 15555 val = 15862 val = 16172 val = 16485 val = 16801 val = 17120 val = 17442 val = 17767 val = 18095 val = 18426 val = 18760 val = 19097 val = 19437 val = 19780 val = 20126 val = 20475 val = 20827 val = 21182 val = 21540 val = 21901 val = 22265 val = 22632 val = 23002 val = 23375 val = 23751 val = 24130 val = 24512 val = 24897 val = 25285 val = 25676 val = 26070 val = 26467 val = 26867 val = 27270 val = 27676 val = 28085 val = 28497 val = 28912 val = 29330 val = 29751 val = 30175 val = 30602 val = 31032 val = 31465 val = 31901 val = 32340 val = 32782 val = 33227 val = 33675 val = 34126 val = 34580 val = 35037 val = 35497 val = 35960 val = 36426 val = 36895 val = 37367 val = 37842 val = 38320 val = 38801 val = 39285 val = 39772 val = 40262 val = 40755 val = 41251 val = 41750 val = 42252 val = 42757 val = 43265 val = 43776 val = 44290 val = 44807 val = 45327 val = 45850 val = 46376 val = 46905 val = 47437 val = 47972 val = 48510 val = 49051 val = 49595 val = 50142 val = 50692 val = 51245 val = 51801 val = 52360 val = 52922 val = 53487 val = 54055 val = 54626 val = 55200 val = 55777 val = 56357 val = 56940 val = 57526 val = 58115 val = 58707 val = 59302 val = 59900 val = 60501 val = 61105 val = 61712 val = 62322 val = 62935 val = 63551 val = 64170 val = 64792 val = 65417 val = 66045 val = 66676 val = 67310 val = 67947 val = 68587 val = 69230 val = 69876 val = 70525 val = 71177 val = 71832 val = 72490 val = 73151 val = 73815 val = 74482 val = 75152 val = 75825 val = 76501 val = 77180 val = 77862 val = 78547 val = 79235 val = 79926 val = 80620 val = 81317 val = 82017 val = 82720 val = 83426 val = 84135 val = 84847 val = 85562 val = 86280 val = 87001 val = 87725 val = 88452 val = 89182 val = 89915 val = 90651 val = 91390 val = 92132 val = 92877 val = 93625 val = 94376 val = 95130 val = 95887 val = 96647 val = 97410 val = 98176 val = 98945 val = 99717 val = 100492 val = 101270 val = 102051 val = 102835 val = 103622 val = 104412 val = 105205 val = 106001 val = 106800 val = 107602 val = 108407 val = 109215 val = 110026 p = 100492 101270 102051 102835 103622 104412 105205 106001 106800 107602 108407 109215 d = 1×12 logical array 0 1 0 1 0 0 1 0 1 0 0 1

12   Pass
x1 = 1000000; x2 = 1010101; [p,d] = pentagonal_numbers(x1,x2) assert(isequal(p,[1000825,1003277,1005732,1008190])) assert(isequal(d,[1,0,0,1]))

val = 1 val = 5 val = 12 val = 22 val = 35 val = 51 val = 70 val = 92 val = 117 val = 145 val = 176 val = 210 val = 247 val = 287 val = 330 val = 376 val = 425 val = 477 val = 532 val = 590 val = 651 val = 715 val = 782 val = 852 val = 925 val = 1001 val = 1080 val = 1162 val = 1247 val = 1335 val = 1426 val = 1520 val = 1617 val = 1717 val = 1820 val = 1926 val = 2035 val = 2147 val = 2262 val = 2380 val = 2501 val = 2625 val = 2752 val = 2882 val = 3015 val = 3151 val = 3290 val = 3432 val = 3577 val = 3725 val = 3876 val = 4030 val = 4187 val = 4347 val = 4510 val = 4676 val = 4845 val = 5017 val = 5192 val = 5370 val = 5551 val = 5735 val = 5922 val = 6112 val = 6305 val = 6501 val = 6700 val = 6902 val = 7107 val = 7315 val = 7526 val = 7740 val = 7957 val = 8177 val = 8400 val = 8626 val = 8855 val = 9087 val = 9322 val = 9560 val = 9801 val = 10045 val = 10292 val = 10542 val = 10795 val = 11051 val = 11310 val = 11572 val = 11837 val = 12105 val = 12376 val = 12650 val = 12927 val = 13207 val = 13490 val = 13776 val = 14065 val = 14357 val = 14652 val = 14950 val = 15251 val = 15555 val = 15862 val = 16172 val = 16485 val = 16801 val = 17120 val = 17442 val = 17767 val = 18095 val = 18426 val = 18760 val = 19097 val = 19437 val = 19780 val = 20126 val = 20475 val = 20827 val = 21182 val = 21540 val = 21901 val = 22265 val = 22632 val = 23002 val = 23375 val = 23751 val = 24130 val = 24512 val = 24897 val = 25285 val = 25676 val = 26070 val = 26467 val = 26867 val = 27270 val = 27676 val = 28085 val = 28497 val = 28912 val = 29330 val = 29751 val = 30175 val = 30602 val = 31032 val = 31465 val = 31901 val = 32340 val = 32782 val = 33227 val = 33675 val = 34126 val = 34580 val = 35037 val = 35497 val = 35960 val = 36426 val = 36895 val = 37367 val = 37842 val = 38320 val = 38801 val = 39285 val = 39772 val = 40262 val = 40755 val = 41251 val = 41750 val = 42252 val = 42757 val = 43265 val = 43776 val = 44290 val = 44807 val = 45327 val = 45850 val = 46376 val = 46905 val = 47437 val = 47972 val = 48510 val = 49051 val = 49595 val = 50142 val = 50692 val = 51245 val = 51801 val = 52360 val = 52922 val = 53487 val = 54055 val = 54626 val = 55200 val = 55777 val = 56357 val = 56940 val = 57526 val = 58115 val = 58707 val = 59302 val = 59900 val = 60501 val = 61105 val = 61712 val = 62322 val = 62935 val = 63551 val = 64170 val = 64792 val = 65417 val = 66045 val = 66676 val = 67310 val = 67947 val = 68587 val = 69230 val = 69876 val = 70525 val = 71177 val = 71832 val = 72490 val = 73151 val = 73815 val = 74482 val = 75152 val = 75825 val = 76501 val = 77180 val = 77862 val = 78547 val = 79235 val = 79926 val = 80620 val = 81317 val = 82017 val = 82720 val = 83426 val = 84135 val = 84847 val = 85562 val = 86280 val = 87001 val = 87725 val = 88452 val = 89182 val = 89915 val = 90651 val = 91390 val = 92132 val = 92877 val = 93625 val = 94376 val = 95130 val = 95887 val = 96647 val = 97410 val = 98176 val = 98945 val = 99717 val = 100492 val = 101270 val = 102051 val = 102835 val = 103622 val = 104412 val = 105205 val = 106001 val = 106800 val = 107602 val = 108407 val = 109215 val = 110026 val = 110840 val = 111657 val = 112477 val = 113300 val = 114126 val = 114955 val = 115787 val = 116622 val = 117460 val = 118301 val = 119145 val = 119992 val = 120842 val = 121695 val = 122551 val = 123410 val = 124272 val = 125137 val = 126005 val = 126876 val = 127750 val = 128627 val = 129507 val = 130390 val = 131276 val = 132165 val = 133057 val = 133952 val = 134850 val = 135751 val = 136655 val = 137562 val = 138472 val = 139385 val = 140301 val = 141220 val = 142142 val = 143067 val = 143995 val = 144926 val = 145860 val = 146797 val = 147737 val = 148680 val = 149626 val = 150575 val = 151527 val = 152482 val = 153440 val = 154401 val = 155365 val = 156332 val = 157302 val = 158275 val = 159251 val = 160230 val = 161212 val = 162197 val = 163185 val = 164176 val = 165170 val = 166167 val = 167167 val = 168170 val = 169176 val = 170185 val = 171197 val = 172212 val = 173230 val = 174251 val = 175275 val = 176302 val = 177332 val = 178365 val = 179401 val = 180440 val = 181482 val = 182527 val = 183575 val = 184626 val = 185680 val = 186737 val = 187797 val = 188860 val = 189926 val = 190995 val = 192067 val = 193142 val = 194220 val = 195301 val = 196385 val = 197472 val = 198562 val = 199655 val = 200751 val = 201850 val = 202952 val = 204057 val = 205165 val = 206276 val = 207390 val = 208507 val = 209627 val = 210750 val = 211876 val = 213005 val = 214137 val = 215272 val = 216410 val = 217551 val = 218695 val = 219842 val = 220992 val = 222145 val = 223301 val = 224460 val = 225622 val = 226787 val = 227955 val = 229126 val = 230300 val = 231477 val = 232657 val = 233840 val = 235026 val = 236215 val = 237407 val = 238602 val = 239800 val = 241001 val = 242205 val = 243412 val = 244622 val = 245835 val = 247051 val = 248270 val = 249492 val = 250717 val = 251945 val = 253176 val = 254410 val = 255647 val = 256887 val = 258130 val = 259376 val = 260625 val = 261877 val = 263132 val = 264390 val = 265651 val = 266915 val = 268182 val = 269452 val = 270725 val = 272001 val = 273280 val = 274562 val = 275847 val = 277135 val = 278426 val = 279720 val = 281017 val = 282317 val = 283620 val = 284926 val = 286235 val = 287547 val = 288862 val = 290180 val = 291501 val = 292825 val = 294152 val = 295482 val = 296815 val = 298151 val = 299490 val = 300832 val = 302177 val = 303525 val = 304876 val = 306230 val = 307587 val = 308947 val = 310310 val = 311676 val = 313045 val = 314417 val = 315792 val = 317170 val = 318551 val = ...

### Community Treasure Hunt

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

Start Hunting!