Cody

Solution 1203009

Submitted on 2 Jun 2017
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(smith(4937775),1))

Error using horzcat Dimensions of matrices being concatenated are not consistent. Error in smith (line 2) ~sum([num2str(x)-'0', '0'-dec2base(factor(x),10)]) & ~isprime(x) Error in TestPoint1 (line 1) assert(isequal(smith(4937775),1))

2   Fail
assert(isequal(smith(1164),0))

Error using horzcat Dimensions of matrices being concatenated are not consistent. Error in smith (line 2) ~sum([num2str(x)-'0', '0'-dec2base(factor(x),10)]) & ~isprime(x) Error in TestPoint2 (line 1) assert(isequal(smith(1164),0))

3   Fail
assert(isequal(smith(19683),1))

Error using horzcat Dimensions of matrices being concatenated are not consistent. Error in smith (line 2) ~sum([num2str(x)-'0', '0'-dec2base(factor(x),10)]) & ~isprime(x) Error in TestPoint3 (line 1) assert(isequal(smith(19683),1))

4   Pass
assert(isequal(smith(11),0)) % Remember - Smith numbers are composite

ans = logical 0

5   Fail
assert(isequal(smith(345741),1))

Error using horzcat Dimensions of matrices being concatenated are not consistent. Error in smith (line 2) ~sum([num2str(x)-'0', '0'-dec2base(factor(x),10)]) & ~isprime(x) Error in TestPoint5 (line 1) assert(isequal(smith(345741),1))

6   Fail
assert(isequal(smith(19876),0))

Error using horzcat Dimensions of matrices being concatenated are not consistent. Error in smith (line 2) ~sum([num2str(x)-'0', '0'-dec2base(factor(x),10)]) & ~isprime(x) Error in TestPoint6 (line 1) assert(isequal(smith(19876),0))

7   Pass
assert(isequal(smith(314159),0))

ans = logical 0

8   Fail
assert(isequal(smith(612985),1))

Error using horzcat Dimensions of matrices being concatenated are not consistent. Error in smith (line 2) ~sum([num2str(x)-'0', '0'-dec2base(factor(x),10)]) & ~isprime(x) Error in TestPoint8 (line 1) assert(isequal(smith(612985),1))

9   Fail
assert(isequal(smith(12379887),1))

Error using horzcat Dimensions of matrices being concatenated are not consistent. Error in smith (line 2) ~sum([num2str(x)-'0', '0'-dec2base(factor(x),10)]) & ~isprime(x) Error in TestPoint9 (line 1) assert(isequal(smith(12379887),1))

10   Pass
assert(isequal(smith(23456789),0))

ans = logical 0