Cody

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

Solution 2880131

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   Fail
assert(isequal(euler029(5,5),[4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125]));

a = 4 27 256 3125

Assertion failed.

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 .^ Matrix dimensions must agree. Error in euler029 (line 9) a = [2:n].^[2:m]'; 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   Fail
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]));

a = 1.0e+10 * 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0017 0.0387 1.0000

Assertion failed.

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

a = 67 b = 33

Error using .^ Matrix dimensions must agree. Error in euler029 (line 9) a = [2:n].^[2:m]'; 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 11) 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]))

Suggested Problems

More from this Author80

Community Treasure Hunt

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

Start Hunting!