Cody

Problem 20. Summing digits

Solution 3934398

Submitted on 1 Dec 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
a = 1; b = 2; out = sumDigits(a); assert(isequal(out, b))

x = 2 sum = 0 z = '2' i = 1 y = 1 sum = 2 i = 2

Output argument "b" (and maybe others) not assigned during call to "sumDigits". Error in Test1 (line 3) out = sumDigits(a);

2   Fail
a = 10; b = 7; out = sumDigits(a); assert(isequal(out, b))

x = 1024 sum = 0 z = '1024' i = 1 y = 4 sum = 1 i = 2 sum = 1 i = 3 sum = 3 i = 4 sum = 7 i = 5

Output argument "b" (and maybe others) not assigned during call to "sumDigits". Error in Test2 (line 3) out = sumDigits(a);

3   Fail
a = 16; b = 25; out = sumDigits(a); assert(isequal(out, b))

x = 65536 sum = 0 z = '65536' i = 1 y = 5 sum = 6 i = 2 sum = 11 i = 3 sum = 16 i = 4 sum = 19 i = 5 sum = 25 i = 6

Output argument "b" (and maybe others) not assigned during call to "sumDigits". Error in Test3 (line 3) out = sumDigits(a);

Suggested Problems

More from this Author95

Community Treasure Hunt

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

Start Hunting!