Cody

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

Solution 2880167

Submitted on 26 Aug 2020
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]));

z = Columns 1 through 14 4 8 9 16 25 27 32 64 81 125 243 256 625 1024 Column 15 3125

2   Fail
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]));

Error using cat Dimensions of arrays being concatenated are not consistent. Error in euler029 (line 10) c = cat(1,a,b'); Error in Test2 (line 1) 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]));

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]));

z = 1.0e+10 * Columns 1 through 17 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 Columns 18 through 34 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 Columns 35 through 51 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0001 0.0001 0.0001 0.0002 0.0002 Columns 52 through 68 0.0002 0.0005 0.0006 0.0010 0.0010 0.0010 0.0017 0.0040 0.0043 0.0060 0.0100 0.0134 0.0282 0.0387 0.1000 0.1074 0.3487 Column 69 1.0000

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

a = 44 b = 8

Error using cat Dimensions of arrays being concatenated are not consistent. Error in euler029 (line 10) c = cat(1,a,b'); Error in Test4 (line 3) assert(isequal(euler029(a,b),euler029(b,a)))

5   Fail
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]))

Error using cat Dimensions of arrays being concatenated are not consistent. Error in euler029 (line 10) c = cat(1,a,b'); Error in Test5 (line 1) 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]))

### Community Treasure Hunt

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

Start Hunting!