Cody

# Problem 1106. I've got the power! (Inspired by Project Euler problem 29)

Solution 1939956

Submitted on 17 Sep 2019 by Paul Morant
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
assert(isequal(euler029(5,5),[4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125]));

z1 = 4×4 uint64 matrix 4 8 16 32 9 27 81 243 16 64 256 1024 25 125 625 3125 z2 = 4×4 uint64 matrix 4 9 16 25 8 27 64 125 16 81 256 625 32 243 1024 3125 z = 1×15 uint64 row vector 4 8 9 16 25 27 32 64 81 125 243 256 625 1024 3125

2   Pass
assert(isequal(euler029(4,15),[4 8 9 16 25 27 32 36 49 64 81 100 121 125 128 144 169 196 216 225 243 256 343 512 625 729 1000 1024 1296 1331 1728 2048 2187 2197 2401 2744 3375 4096 6561 8192 10000 14641 16384 19683 20736 28561 32768 38416 50625 59049 65536 177147 262144 531441 1048576 1594323 4194304 4782969 14348907 16777216 67108864 268435456 1073741824]));

z1 = 3×14 uint64 matrix Columns 1 through 13 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 9 27 81 243 729 2187 6561 19683 59049 177147 531441 1594323 4782969 16 64 256 1024 4096 16384 65536 262144 1048576 4194304 16777216 67108864 268435456 Column 14 32768 14348907 1073741824 z2 = 3×14 uint64 matrix 4 9 16 25 36 49 64 81 100 121 144 169 196 225 8 27 64 125 216 343 512 729 1000 1331 1728 2197 2744 3375 16 81 256 625 1296 2401 4096 6561 10000 14641 20736 28561 38416 50625 z = 1×63 uint64 row vector Columns 1 through 13 4 8 9 16 25 27 32 36 49 64 81 100 121 Columns 14 through 26 125 128 144 169 196 216 225 243 256 343 512 625 729 Columns 27 through 39 1000 1024 1296 1331 1728 2048 2187 2197 2401 2744 3375 4096 6561 Columns 40 through 52 8192 10000 14641 16384 19683 20736 28561 32768 38416 50625 59049 65536 177147 Columns 53 through 63 262144 531441 1048576 1594323 4194304 4782969 14348907 16777216 67108864 268435456 1073741824

3   Pass
assert(isequal(euler029(10,10),[4,8,9,16,25,27,32,36,49,64,81,100,125,128,216,243,256,343,512,625,729,1000,1024,1296,2187,2401,3125,4096,6561,7776,10000,15625,16384,16807,19683,32768,46656,59049,65536,78125,100000,117649,262144,279936,390625,531441,823543,1000000,1048576,1679616,1953125,2097152,4782969,5764801,9765625,10000000,10077696,16777216,40353607,43046721,60466176,100000000,134217728,282475249,387420489,1000000000,1073741824,3486784401,10000000000]));

z1 = 9×9 uint64 matrix 4 8 16 32 64 128 256 512 1024 9 27 81 243 729 2187 6561 19683 59049 16 64 256 1024 4096 16384 65536 262144 1048576 25 125 625 3125 15625 78125 390625 1953125 9765625 36 216 1296 7776 46656 279936 1679616 10077696 60466176 49 343 2401 16807 117649 823543 5764801 40353607 282475249 64 512 4096 32768 262144 2097152 16777216 134217728 1073741824 81 729 6561 59049 531441 4782969 43046721 387420489 3486784401 100 1000 10000 100000 1000000 10000000 100000000 1000000000 10000000000 z2 = 9×9 uint64 matrix 4 9 16 25 36 49 64 81 100 8 27 64 125 216 343 512 729 1000 16 81 256 625 1296 2401 4096 6561 10000 32 243 1024 3125 7776 16807 32768 59049 100000 64 729 4096 15625 46656 117649 262144 531441 1000000 128 2187 16384 78125 279936 823543 2097152 4782969 10000000 256 6561 65536 390625 1679616 5764801 16777216 43046721 100000000 512 19683 262144 1953125 10077696 40353607 134217728 387420489 1000000000 1024 59049 1048576 9765625 60466176 282475249 1073741824 3486784401 10000000000 z = 1×69 uint64 row vector Columns 1 through 12 4 8 9 16 25 27 32 36 49 64 81 100 Columns 13 through 24 125 128 216 243 256 343 512 625 729 1000 1024 1296 Columns 25 through 36 2187 2401 3125 4096 6561 7776 10000 15625 16384 16807 19683 32768 Columns 37 through 48 46656 59049 65536 78125 100000 117649 262144 279936 390625 531441 823543 1000000 Columns 49 through 60 1048576 1679616 1953125 2097152 4782969 5764801 9765625 10000000 10077696 16777216 40353607 43046721 Columns 61 through 69 60466176 100000000 134217728 282475249 387420489 1000000000 1073741824 3486784401 10000000000

4   Pass
a=ceil(rand*80)+2 b=ceil(rand*80)+2 assert(isequal(euler029(a,b),euler029(b,a)))

a = 65 b = 17 z1 = 64×16 uint64 matrix Columns 1 through 7 4 8 16 32 64 128 256 9 27 81 243 729 2187 6561 16 64 256 1024 4096 16384 65536 25 125 625 3125 15625 78125 390625 36 216 1296 7776 46656 279936 1679616 49 343 2401 16807 117649 823543 5764801 64 512 4096 32768 262144 2097152 16777216 81 729 6561 59049 531441 4782969 43046721 100 1000 10000 100000 1000000 10000000 100000000 121 1331 14641 161051 1771561 19487171 214358881 144 1728 20736 248832 2985984 35831808 429981696 169 2197 28561 371293 4826809 62748517 815730721 196 2744 38416 537824 7529536 105413504 1475789056 225 3375 50625 759375 11390625 170859375 2562890625 256 4096 65536 1048576 16777216 268435456 4294967296 289 4913 83521 1419857 24137569 410338673 6975757441 324 5832 104976 1889568 34012224 612220032 11019960576 361 6859 130321 2476099 47045881 893871739 16983563041 400 8000 160000 3200000 64000000 1280000000 25600000000 441 9261 194481 4084101 85766121 1801088541 37822859361 484 10648 234256 5153632 113379904 2494357888 54875873536 529 12167 279841 6436343 148035889 3404825447 78310985281 576 13824 331776 7962624 191102976 4586471424 110075314176 625 15625 390625 9765625 244140625 6103515625 152587890625 676 17576 456976 11881376 308915776 8031810176 208827064576 729 19683 531441 14348907 387420489 10460353203 282429536481 784 21952 614656 17210368 481890304 13492928512 377801998336 841 24389 707281 20511149 594823321 17249876309 500246412961 900 27000 810000 24300000 729000000 21870000000 656100000000 961 29791 923521 28629151 887503681 27512614111 852891037441 1024 32768 1048576 33554432 1073741824 34359738368 1099511627776 1089 35937 1185921 39135393 1291467969 42618442977 1406408618241 1156 39304 1336336 45435424 1544804416 52523350144 1785793904896 1225 42875 1500625 52521875 1838265625 64339296875 2251875390625 1296 46656 1679616 60466176 2176782336 78364164096 2821109907456 1369 50653 1874161 69343957 2565726409 94931877133 3512479453921 1444 54872 2085136 79235168 3010936384 114415582592 4347792138496 1521 59319 2313441 90224199 3518743761 137231006679 5352009260481 1600 64000 2560000 102400000 4096000000 163840000000 6553600000000 1681 68921 2825761 115856201 4750104241 194754273881 7984925229121 1764 74088 3111696 130691232 5489031744 230539333248 9682651996416 1849 79507 3418801 147008443 6321363049 271818611107 11688200277601 1936 85184 3748096 164916224 7256313856 319277809664 14048223625216 2025 91125 4100625 184528125 8303765625 373669453125 16815125390625 2116 97336 4477456 205962976 9474296896 435817657216 20047612231936 2209 103823 4879681 229345007 10779215329 506623120463 23811286661761 2304 110592 5308416 254803968 12230590464 587068342272 28179280429056 2401 117649 5764801 282475249 13841287201 678223072849 33232930569601 2500 125000 6250000 312500000 15625000000 781250000000 39062500000000 2601 132651 6765201 345025251 17596287801 897410677851 45767944570401 2704 140608 7311616 380204032 19770609664 1028071702528 53459728531456 2809 148877 7890481 418195493 22164361129 1174711139837 62259690411361 2916 157464 8503056 459165024 24794911296 1338925209984 72301961339136 3025 166375 9150625 503284375 27680640625 1522435234375 83733937890625 3136 175616 9834496 550731776 30840979456 1727094849536 96717311574016 3249 185193 10556001 601692057 34296447249 1954897493193 111429157112001 3364 195112 11316496 656356768 38068692544 2207984167552 128063081718016 3481 205379 12117361 714924299 42180533641 2488651484819 146830437604321 3600 216000 12960000 777600000 46656000000 2799360000000 167961600000000 3721 226981 13845841 844596301 51520374361 3142742836021 191707312997281 3844 238328 14776336 916132832 56800235584 3521614606208 218340105584896 3969 ...

5   Pass
assert(isequal(euler029(30,2),[4,8,9,16,25,32,36,49,64,81,100,121,128,144,169,196,225,256,289,324,361,400,441,484,512,529,576,625,676,729,784,841,900,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912,1073741824]))

z1 = 29×1 uint64 column vector 4 9 16 25 36 49 64 81 100 121 144 169 196 225 256 289 324 361 400 441 484 529 576 625 676 729 784 841 900 z2 = 29×1 uint64 column vector 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 134217728 268435456 536870912 1073741824 z = 1×54 uint64 row vector Columns 1 through 13 4 8 9 16 25 32 36 49 64 81 100 121 128 Columns 14 through 26 144 169 196 225 256 289 324 361 400 441 484 512 529 Columns 27 through 39 576 625 676 729 784 841 900 1024 2048 4096 8192 16384 32768 Columns 40 through 52 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 134217728 268435456 Columns 53 through 54 536870912 1073741824