Cody

Problem 20. Summing digits

Solution 288422

Submitted on 24 Jul 2013 by Peter Lindberg
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
%% a = 1; b = 2; out = sumDigits(a); assert(isequal(out, b))

alt = 2 i = 1 const = 10 const2 = 10 x = 2 alt = 0 bb = 2 i = 2 const2 = 100 b = 2

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

alt = 1024 i = 1 const = 10 const2 = 10 x = 4 alt = 1020 bb = 4 i = 2 const2 = 100 x = 4 20 alt = 1000 bb = 4 2 i = 3 const2 = 1000 x = 4 20 0 alt = 1000 bb = 4 2 0 i = 4 const2 = 10000 x = 4 20 0 1000 alt = 0 bb = 4 2 0 1 i = 5 const2 = 100000 b = 7

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

alt = 65536 i = 1 const = 10 const2 = 10 x = 6 alt = 65530 bb = 6 i = 2 const2 = 100 x = 6 30 alt = 65500 bb = 6 3 i = 3 const2 = 1000 x = 6 30 500 alt = 65000 bb = 6 3 5 i = 4 const2 = 10000 x = 6 30 500 5000 alt = 60000 bb = 6 3 5 5 i = 5 const2 = 100000 x = 6 30 500 5000 60000 alt = 0 bb = 6 3 5 5 6 i = 6 const2 = 1000000 b = 25