Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 328442

Submitted on 3 Oct 2013 by Chris E.

Correct

89Size
Leading solution size is 10.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
x = 1000;
y_correct = 233168;
assert(isequal(euler001(x),y_correct))
c =
  Columns 1 through 8
           3           5           6           9          10          12          15          18
  Columns 9 through 16
          20          21          24          25          27          30          33          35
  Columns 17 through 24
          36          39          40          42          45          48          50          51
  Columns 25 through 32
          54          55          57          60          63          65          66          69
  Columns 33 through 40
          70          72          75          78          80          81          84          85
  Columns 41 through 48
          87          90          93          95          96          99         100         102
  Columns 49 through 56
         105         108         110         111         114         115         117         120
  Columns 57 through 64
         123         125         126         129         130         132         135         138
  Columns 65 through 72
         140         141         144         145         147         150         153         155
  Columns 73 through 80
         156         159         160         162         165         168         170         171
  Columns 81 through 88
         174         175         177         180         183         185         186         189
  Columns 89 through 96
         190         192         195         198         200         201         204         205
  Columns 97 through 104
         207         210         213         215         216         219         220         222
  Columns 105 through 112
         225         228         230         231         234         235         237         240
  Columns 113 through 120
         243         245         246         249         250         252         255         258
  Columns 121 through 128
         260         261         264         265         267         270         273         275
  Columns 129 through 136
         276         279         280         282         285         288         290         291
  Columns 137 through 144
         294         295         297         300         303         305         306         309
  Columns 145 through 152
         310         312         315         318         320         321         324         325
  Columns 153 through 160
         327         330         333         335         336         339         340         342
  Columns 161 through 168
         345         348         350         351         354         355         357         360
  Columns 169 through 176
         363         365         366         369         370         372         375         378
  Columns 177 through 184
         380         381         384         385         387         390         393         395
  Columns 185 through 192
         396         399         400         402         405         408         410         411
  Columns 193 through 200
         414         415         417         420         423         425         426         429
  Columns 201 through 208
         430         432         435         438         440         441         444         445
  Columns 209 through 216
         447         450         453         455         456         459         460         462
  Columns 217 through 224
         465         468         470         471         474         475         477         480
  Columns 225 through 232
         483         485         486         489         490         492         495         498
  Columns 233 through 240
         500         501         504         505         507         510         513         515
  Columns 241 through 248
         516         519         520         522         525         528         530         531
  Columns 249 through 256
         534         535         537         540         543         545         546         549
  Columns 257 through 264
         550         552         555         558         560         561         564         565
  Columns 265 through 272
         567         570         573         575         576         579         580         582
  Columns 273 through 280
         585         588         590         591         594         595         597         600
  Columns 281 through 288
         603         605         606         609         610         612         615         618
  Columns 289 through 296
         620         621         624         625         627         630         633         635
  Columns 297 through 304
         636         639         640         642         645         648         650         651
  Columns 305 through 312
         654         655         657         660         663         665         666         669
  Columns 313 through 320
         670         672         675         678         680         681         684         685
  Columns 321 through 328
         687         690         693         695         696         699         700         702
  Columns 329 through 336
         705         708         710         711         714         715         717         720
  Columns 337 through 344
         723         725         726         729         730         732         735         738
  Columns 345 through 352
         740         741         744         745         747         750         753         755
  Columns 353 through 360
         756         759         760         762         765         768         770         771
  Columns 361 through 368
         774         775         777         780         783         785         786         789
  Columns 369 through 376
         790         792         795         798         800         801         804         805
  Columns 377 through 384
         807         810         813         815         816         819         820         822
  Columns 385 through 392
         825         828         830         831         834         835         837         840
  Columns 393 through 400
         843         845         846         849         850         852         855         858
  Columns 401 through 408
         860         861         864         865         867         870         873         875
  Columns 409 through 416
         876         879         880         882         885         888         890         891
  Columns 417 through 424
         894         895         897         900         903         905         906         909
  Columns 425 through 432
         910         912         915         918         920         921         924         925
  Columns 433 through 440
         927         930         933         935         936         939         940         942
  Columns 441 through 448
         945         948         950         951         954         955         957         960
  Columns 449 through 456
         963         965         966         969         970         972         975         978
  Columns 457 through 464
         980         981         984         985         987         990         993         995
  Columns 465 through 467
         996         999        1000
y =
      233168
2
Pass
 
%%
x = 4000;
y_correct = 3732668;
assert(isequal(euler001(x),y_correct))
c =
  Columns 1 through 8
           3           5           6           9          10          12          15          18
  Columns 9 through 16
          20          21          24          25          27          30          33          35
  Columns 17 through 24
          36          39          40          42          45          48          50          51
  Columns 25 through 32
          54          55          57          60          63          65          66          69
  Columns 33 through 40
          70          72          75          78          80          81          84          85
  Columns 41 through 48
          87          90          93          95          96          99         100         102
  Columns 49 through 56
         105         108         110         111         114         115         117         120
  Columns 57 through 64
         123         125         126         129         130         132         135         138
  Columns 65 through 72
         140         141         144         145         147         150         153         155
  Columns 73 through 80
         156         159         160         162         165         168         170         171
  Columns 81 through 88
         174         175         177         180         183         185         186         189
  Columns 89 through 96
         190         192         195         198         200         201         204         205
  Columns 97 through 104
         207         210         213         215         216         219         220         222
  Columns 105 through 112
         225         228         230         231         234         235         237         240
  Columns 113 through 120
         243         245         246         249         250         252         255         258
  Columns 121 through 128
         260         261         264         265         267         270         273         275
  Columns 129 through 136
         276         279         280         282         285         288         290         291
  Columns 137 through 144
         294         295         297         300         303         305         306         309
  Columns 145 through 152
         310         312         315         318         320         321         324         325
  Columns 153 through 160
         327         330         333         335         336         339         340         342
  Columns 161 through 168
         345         348         350         351         354         355         357         360
  Columns 169 through 176
         363         365         366         369         370         372         375         378
  Columns 177 through 184
         380         381         384         385         387         390         393         395
  Columns 185 through 192
         396         399         400         402         405         408         410         411
  Columns 193 through 200
         414         415         417         420         423         425         426         429
  Columns 201 through 208
         430         432         435         438         440         441         444         445
  Columns 209 through 216
         447         450         453         455         456         459         460         462
  Columns 217 through 224
         465         468         470         471         474         475         477         480
  Columns 225 through 232
         483         485         486         489         490         492         495         498
  Columns 233 through 240
         500         501         504         505         507         510         513         515
  Columns 241 through 248
         516         519         520         522         525         528         530         531
  Columns 249 through 256
         534         535         537         540         543         545         546         549
  Columns 257 through 264
         550         552         555         558         560         561         564         565
  Columns 265 through 272
         567         570         573         575         576         579         580         582
  Columns 273 through 280
         585         588         590         591         594         595         597         600
  Columns 281 through 288
         603         605         606         609         610         612         615         618
  Columns 289 through 296
         620         621         624         625         627         630         633         635
  Columns 297 through 304
         636         639         640         642         645         648         650         651
  Columns 305 through 312
         654         655         657         660         663         665         666         669
  Columns 313 through 320
         670         672         675         678         680         681         684         685
  Columns 321 through 328
         687         690         693         695         696         699         700         702
  Columns 329 through 336
         705         708         710         711         714         715         717         720
  Columns 337 through 344
         723         725         726         729         730         732         735         738
  Columns 345 through 352
         740         741         744         745         747         750         753         755
  Columns 353 through 360
         756         759         760         762         765         768         770         771
  Columns 361 through 368
         774         775         777         780         783         785         786         789
  Columns 369 through 376
         790         792         795         798         800         801         804         805
  Columns 377 through 384
         807         810         813         815         816         819         820         822
  Columns 385 through 392
         825         828         830         831         834         835         837         840
  Columns 393 through 400
         843         845         846         849         850         852         855         858
  Columns 401 through 408
         860         861         864         865         867         870         873         875
  Columns 409 through 416
         876         879         880         882         885         888         890         891
  Columns 417 through 424
         894         895         897         900         903         905         906         909
  Columns 425 through 432
         910         912         915         918         920         921         924         925
  Columns 433 through 440
         927         930         933         935         936         939         940         942
  Columns 441 through 448
         945         948         950         951         954         955         957         960
  Columns 449 through 456
         963         965         966         969         970         972         975         978
  Columns 457 through 464
         980         981         984         985         987         990         993         995
  Columns 465 through 472
         996         999        1000        1002        1005        1008        1010        1011
  Columns 473 through 480
        1014        1015        1017        1020        1023        1025        1026        1029
  Columns 481 through 488
        1030        1032        1035        1038        1040        1041        1044        1045
  Columns 489 through 496
        1047        1050        1053        1055        1056        1059        1060        1062
  Columns 497 through 504
        1065        1068        1070        1071        1074        1075        1077        1080
  Columns 505 through 512
        1083        1085        1086        1089        1090        1092        1095        1098
  Columns 513 through 520
        1100        1101        1104        1105        1107        1110        1113        1115
  Columns 521 through 528
        1116        1119        1120        1122        1125        1128        1130        1131
  Columns 529 through 536
        1134        1135        1137        1140        1143        1145        1146        1149
  Columns 537 through 544
        1150        1152        1155        1158        1160        1161        1164        1165
  Columns 545 through 552
        1167        1170        1173        1175        1176        1179        1180        1182
  Columns 553 through 560
        1185        1188        1190        1191        1194        1195        1197        1200
  Columns 561 through 568
        1203        1205        1206        1209        1210        1212        1215        1218
  Columns 569 through 576
        1220        1221        1224        1225        1227        1230        1233        1235
  Columns 577 through 584
        1236        1239        1240        1242        1245        1248        1250        1251
  Columns 585 through 592
        1254        1255        1257        1260        1263        1265        1266        1269
  Columns 593 through 600
        1270        1272        1275        1278        1280        1281        1284        1285
  Columns 601 through 608
        1287        1290        1293        1295        1296        1299        1300        1302
  Columns 609 through 616
        1305        1308        1310        1311        1314        1315        1317        1320
  Columns 617 through 624
        1323        1325        1326        1329        1330        1332        1335        1338
  Columns 625 through 632
        1340        1341        1344        1345        1347        1350        1353        1355
  Columns 633 through 640
        1356        1359        1360        1362        1365        1368        1370        1371
  Columns 641 through 648
        1374        1375        1377        1380        1383        1385        1386        1389
  Columns 649 through 656
        1390        1392        13...
3
Pass
 
%%
x = 2340;
y_correct = 1276470;
assert(isequal(euler001(x),y_correct))
c =
  Columns 1 through 8
           3           5           6           9          10          12          15          18
  Columns 9 through 16
          20          21          24          25          27          30          33          35
  Columns 17 through 24
          36          39          40          42          45          48          50          51
  Columns 25 through 32
          54          55          57          60          63          65          66          69
  Columns 33 through 40
          70          72          75          78          80          81          84          85
  Columns 41 through 48
          87          90          93          95          96          99         100         102
  Columns 49 through 56
         105         108         110         111         114         115         117         120
  Columns 57 through 64
         123         125         126         129         130         132         135         138
  Columns 65 through 72
         140         141         144         145         147         150         153         155
  Columns 73 through 80
         156         159         160         162         165         168         170         171
  Columns 81 through 88
         174         175         177         180         183         185         186         189
  Columns 89 through 96
         190         192         195         198         200         201         204         205
  Columns 97 through 104
         207         210         213         215         216         219         220         222
  Columns 105 through 112
         225         228         230         231         234         235         237         240
  Columns 113 through 120
         243         245         246         249         250         252         255         258
  Columns 121 through 128
         260         261         264         265         267         270         273         275
  Columns 129 through 136
         276         279         280         282         285         288         290         291
  Columns 137 through 144
         294         295         297         300         303         305         306         309
  Columns 145 through 152
         310         312         315         318         320         321         324         325
  Columns 153 through 160
         327         330         333         335         336         339         340         342
  Columns 161 through 168
         345         348         350         351         354         355         357         360
  Columns 169 through 176
         363         365         366         369         370         372         375         378
  Columns 177 through 184
         380         381         384         385         387         390         393         395
  Columns 185 through 192
         396         399         400         402         405         408         410         411
  Columns 193 through 200
         414         415         417         420         423         425         426         429
  Columns 201 through 208
         430         432         435         438         440         441         444         445
  Columns 209 through 216
         447         450         453         455         456         459         460         462
  Columns 217 through 224
         465         468         470         471         474         475         477         480
  Columns 225 through 232
         483         485         486         489         490         492         495         498
  Columns 233 through 240
         500         501         504         505         507         510         513         515
  Columns 241 through 248
         516         519         520         522         525         528         530         531
  Columns 249 through 256
         534         535         537         540         543         545         546         549
  Columns 257 through 264
         550         552         555         558         560         561         564         565
  Columns 265 through 272
         567         570         573         575         576         579         580         582
  Columns 273 through 280
         585         588         590         591         594         595         597         600
  Columns 281 through 288
         603         605         606         609         610         612         615         618
  Columns 289 through 296
         620         621         624         625         627         630         633         635
  Columns 297 through 304
         636         639         640         642         645         648         650         651
  Columns 305 through 312
         654         655         657         660         663         665         666         669
  Columns 313 through 320
         670         672         675         678         680         681         684         685
  Columns 321 through 328
         687         690         693         695         696         699         700         702
  Columns 329 through 336
         705         708         710         711         714         715         717         720
  Columns 337 through 344
         723         725         726         729         730         732         735         738
  Columns 345 through 352
         740         741         744         745         747         750         753         755
  Columns 353 through 360
         756         759         760         762         765         768         770         771
  Columns 361 through 368
         774         775         777         780         783         785         786         789
  Columns 369 through 376
         790         792         795         798         800         801         804         805
  Columns 377 through 384
         807         810         813         815         816         819         820         822
  Columns 385 through 392
         825         828         830         831         834         835         837         840
  Columns 393 through 400
         843         845         846         849         850         852         855         858
  Columns 401 through 408
         860         861         864         865         867         870         873         875
  Columns 409 through 416
         876         879         880         882         885         888         890         891
  Columns 417 through 424
         894         895         897         900         903         905         906         909
  Columns 425 through 432
         910         912         915         918         920         921         924         925
  Columns 433 through 440
         927         930         933         935         936         939         940         942
  Columns 441 through 448
         945         948         950         951         954         955         957         960
  Columns 449 through 456
         963         965         966         969         970         972         975         978
  Columns 457 through 464
         980         981         984         985         987         990         993         995
  Columns 465 through 472
         996         999        1000        1002        1005        1008        1010        1011
  Columns 473 through 480
        1014        1015        1017        1020        1023        1025        1026        1029
  Columns 481 through 488
        1030        1032        1035        1038        1040        1041        1044        1045
  Columns 489 through 496
        1047        1050        1053        1055        1056        1059        1060        1062
  Columns 497 through 504
        1065        1068        1070        1071        1074        1075        1077        1080
  Columns 505 through 512
        1083        1085        1086        1089        1090        1092        1095        1098
  Columns 513 through 520
        1100        1101        1104        1105        1107        1110        1113        1115
  Columns 521 through 528
        1116        1119        1120        1122        1125        1128        1130        1131
  Columns 529 through 536
        1134        1135        1137        1140        1143        1145        1146        1149
  Columns 537 through 544
        1150        1152        1155        1158        1160        1161        1164        1165
  Columns 545 through 552
        1167        1170        1173        1175        1176        1179        1180        1182
  Columns 553 through 560
        1185        1188        1190        1191        1194        1195        1197        1200
  Columns 561 through 568
        1203        1205        1206        1209        1210        1212        1215        1218
  Columns 569 through 576
        1220        1221        1224        1225        1227        1230        1233        1235
  Columns 577 through 584
        1236        1239        1240        1242        1245        1248        1250        1251
  Columns 585 through 592
        1254        1255        1257        1260        1263        1265        1266        1269
  Columns 593 through 600
        1270        1272        1275        1278        1280        1281        1284        1285
  Columns 601 through 608
        1287        1290        1293        1295        1296        1299        1300        1302
  Columns 609 through 616
        1305        1308        1310        1311        1314        1315        1317        1320
  Columns 617 through 624
        1323        1325        1326        1329        1330        1332        1335        1338
  Columns 625 through 632
        1340        1341        1344        1345        1347        1350        1353        1355
  Columns 633 through 640
        1356        1359        1360        1362        1365        1368        1370        1371
  Columns 641 through 648
        1374        1375        1377        1380        1383        1385        1386        1389
  Columns 649 through 656
        1390        1392        13...
4
Pass
 
%%
x = 2341;
y_correct = 1278810;
assert(isequal(euler001(x),y_correct))
c =
  Columns 1 through 8
           3           5           6           9          10          12          15          18
  Columns 9 through 16
          20          21          24          25          27          30          33          35
  Columns 17 through 24
          36          39          40          42          45          48          50          51
  Columns 25 through 32
          54          55          57          60          63          65          66          69
  Columns 33 through 40
          70          72          75          78          80          81          84          85
  Columns 41 through 48
          87          90          93          95          96          99         100         102
  Columns 49 through 56
         105         108         110         111         114         115         117         120
  Columns 57 through 64
         123         125         126         129         130         132         135         138
  Columns 65 through 72
         140         141         144         145         147         150         153         155
  Columns 73 through 80
         156         159         160         162         165         168         170         171
  Columns 81 through 88
         174         175         177         180         183         185         186         189
  Columns 89 through 96
         190         192         195         198         200         201         204         205
  Columns 97 through 104
         207         210         213         215         216         219         220         222
  Columns 105 through 112
         225         228         230         231         234         235         237         240
  Columns 113 through 120
         243         245         246         249         250         252         255         258
  Columns 121 through 128
         260         261         264         265         267         270         273         275
  Columns 129 through 136
         276         279         280         282         285         288         290         291
  Columns 137 through 144
         294         295         297         300         303         305         306         309
  Columns 145 through 152
         310         312         315         318         320         321         324         325
  Columns 153 through 160
         327         330         333         335         336         339         340         342
  Columns 161 through 168
         345         348         350         351         354         355         357         360
  Columns 169 through 176
         363         365         366         369         370         372         375         378
  Columns 177 through 184
         380         381         384         385         387         390         393         395
  Columns 185 through 192
         396         399         400         402         405         408         410         411
  Columns 193 through 200
         414         415         417         420         423         425         426         429
  Columns 201 through 208
         430         432         435         438         440         441         444         445
  Columns 209 through 216
         447         450         453         455         456         459         460         462
  Columns 217 through 224
         465         468         470         471         474         475         477         480
  Columns 225 through 232
         483         485         486         489         490         492         495         498
  Columns 233 through 240
         500         501         504         505         507         510         513         515
  Columns 241 through 248
         516         519         520         522         525         528         530         531
  Columns 249 through 256
         534         535         537         540         543         545         546         549
  Columns 257 through 264
         550         552         555         558         560         561         564         565
  Columns 265 through 272
         567         570         573         575         576         579         580         582
  Columns 273 through 280
         585         588         590         591         594         595         597         600
  Columns 281 through 288
         603         605         606         609         610         612         615         618
  Columns 289 through 296
         620         621         624         625         627         630         633         635
  Columns 297 through 304
         636         639         640         642         645         648         650         651
  Columns 305 through 312
         654         655         657         660         663         665         666         669
  Columns 313 through 320
         670         672         675         678         680         681         684         685
  Columns 321 through 328
         687         690         693         695         696         699         700         702
  Columns 329 through 336
         705         708         710         711         714         715         717         720
  Columns 337 through 344
         723         725         726         729         730         732         735         738
  Columns 345 through 352
         740         741         744         745         747         750         753         755
  Columns 353 through 360
         756         759         760         762         765         768         770         771
  Columns 361 through 368
         774         775         777         780         783         785         786         789
  Columns 369 through 376
         790         792         795         798         800         801         804         805
  Columns 377 through 384
         807         810         813         815         816         819         820         822
  Columns 385 through 392
         825         828         830         831         834         835         837         840
  Columns 393 through 400
         843         845         846         849         850         852         855         858
  Columns 401 through 408
         860         861         864         865         867         870         873         875
  Columns 409 through 416
         876         879         880         882         885         888         890         891
  Columns 417 through 424
         894         895         897         900         903         905         906         909
  Columns 425 through 432
         910         912         915         918         920         921         924         925
  Columns 433 through 440
         927         930         933         935         936         939         940         942
  Columns 441 through 448
         945         948         950         951         954         955         957         960
  Columns 449 through 456
         963         965         966         969         970         972         975         978
  Columns 457 through 464
         980         981         984         985         987         990         993         995
  Columns 465 through 472
         996         999        1000        1002        1005        1008        1010        1011
  Columns 473 through 480
        1014        1015        1017        1020        1023        1025        1026        1029
  Columns 481 through 488
        1030        1032        1035        1038        1040        1041        1044        1045
  Columns 489 through 496
        1047        1050        1053        1055        1056        1059        1060        1062
  Columns 497 through 504
        1065        1068        1070        1071        1074        1075        1077        1080
  Columns 505 through 512
        1083        1085        1086        1089        1090        1092        1095        1098
  Columns 513 through 520
        1100        1101        1104        1105        1107        1110        1113        1115
  Columns 521 through 528
        1116        1119        1120        1122        1125        1128        1130        1131
  Columns 529 through 536
        1134        1135        1137        1140        1143        1145        1146        1149
  Columns 537 through 544
        1150        1152        1155        1158        1160        1161        1164        1165
  Columns 545 through 552
        1167        1170        1173        1175        1176        1179        1180        1182
  Columns 553 through 560
        1185        1188        1190        1191        1194        1195        1197        1200
  Columns 561 through 568
        1203        1205        1206        1209        1210        1212        1215        1218
  Columns 569 through 576
        1220        1221        1224        1225        1227        1230        1233        1235
  Columns 577 through 584
        1236        1239        1240        1242        1245        1248        1250        1251
  Columns 585 through 592
        1254        1255        1257        1260        1263        1265        1266        1269
  Columns 593 through 600
        1270        1272        1275        1278        1280        1281        1284        1285
  Columns 601 through 608
        1287        1290        1293        1295        1296        1299        1300        1302
  Columns 609 through 616
        1305        1308        1310        1311        1314        1315        1317        1320
  Columns 617 through 624
        1323        1325        1326        1329        1330        1332        1335        1338
  Columns 625 through 632
        1340        1341        1344        1345        1347        1350        1353        1355
  Columns 633 through 640
        1356        1359        1360        1362        1365        1368        1370        1371
  Columns 641 through 648
        1374        1375        1377        1380        1383        1385        1386        1389
  Columns 649 through 656
        1390        1392        13...