Cody

Problem 44227. Divisible by 21

Solution 1251734

Submitted on 15 Aug 2017
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

Test Suite

Test Status Code Input and Output
1   Fail
x = 11; assert(isequal(divisible_by_21(x),0))

Error using factor (line 20) N must be a scalar. Error in divisible_by_21 (line 2) ismember(7,factor(str2num(fliplr(sprintf('%c*1+%c*3+%c*2+%c*6+%c*4+%c*5+',fliplr(x)))))) && ismember(3, factor(sum(x))); Error in Test1 (line 1) x = 11; assert(isequal(divisible_by_21(x),0))

2   Fail
x = 20; assert(isequal(divisible_by_21(x),0))

Error using factor (line 20) N must be a scalar. Error in divisible_by_21 (line 2) ismember(7,factor(str2num(fliplr(sprintf('%c*1+%c*3+%c*2+%c*6+%c*4+%c*5+',fliplr(x)))))) && ismember(3, factor(sum(x))); Error in Test2 (line 1) x = 20; assert(isequal(divisible_by_21(x),0))

3   Fail
x = 217; assert(isequal(divisible_by_21(x),0))

Error using factor (line 20) N must be a scalar. Error in divisible_by_21 (line 2) ismember(7,factor(str2num(fliplr(sprintf('%c*1+%c*3+%c*2+%c*6+%c*4+%c*5+',fliplr(x)))))) && ismember(3, factor(sum(x))); Error in Test3 (line 1) x = 217; assert(isequal(divisible_by_21(x),0))

4   Fail
x = 231; assert(isequal(divisible_by_21(x),1))

Error using factor (line 20) N must be a scalar. Error in divisible_by_21 (line 2) ismember(7,factor(str2num(fliplr(sprintf('%c*1+%c*3+%c*2+%c*6+%c*4+%c*5+',fliplr(x)))))) && ismember(3, factor(sum(x))); Error in Test4 (line 1) x = 231; assert(isequal(divisible_by_21(x),1))

5   Fail
x = 2240; assert(isequal(divisible_by_21(x),0))

Error using factor (line 20) N must be a scalar. Error in divisible_by_21 (line 2) ismember(7,factor(str2num(fliplr(sprintf('%c*1+%c*3+%c*2+%c*6+%c*4+%c*5+',fliplr(x)))))) && ismember(3, factor(sum(x))); Error in Test5 (line 1) x = 2240; assert(isequal(divisible_by_21(x),0))

6   Fail
x = 1236123; assert(isequal(divisible_by_21(x),1))

Error using factor (line 20) N must be a scalar. Error in divisible_by_21 (line 2) ismember(7,factor(str2num(fliplr(sprintf('%c*1+%c*3+%c*2+%c*6+%c*4+%c*5+',fliplr(x)))))) && ismember(3, factor(sum(x))); Error in Test6 (line 1) x = 1236123; assert(isequal(divisible_by_21(x),1))

Suggested Problems

More from this Author14

Community Treasure Hunt

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

Start Hunting!