Cody

Problem 43019. Iterative sum of digits of 2^n number

Solution 2766958

Submitted on 1 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
n = 0; y_correct = 1; assert(isequal(your_fcn_name(n),y_correct))

2   Pass
n = 1; y_correct = 2; assert(isequal(your_fcn_name(n),y_correct))

3   Fail
n = 6; y_correct = 1; assert(isequal(your_fcn_name(n),y_correct))

Index exceeds the number of array elements (1). Error in your_fcn_name (line 6) num=sum(array); Error in Test3 (line 3) assert(isequal(your_fcn_name(n),y_correct))

4   Fail
n = 21; y_correct = 8; assert(isequal(your_fcn_name(n),y_correct))

Array indices must be positive integers or logical values. Error in your_fcn_name (line 6) num=sum(array); Error in Test4 (line 3) assert(isequal(your_fcn_name(n),y_correct))

5   Fail
n = 111; y_correct = 9; assert(isequal(your_fcn_name(n),y_correct))

Array indices must be positive integers or logical values. Error in your_fcn_name (line 6) num=sum(array); Error in Test5 (line 3) assert(isequal(your_fcn_name(n),y_correct))