Cody

# Problem 45384. Sum! Sum! Sum!

Solution 2190921

Submitted on 3 Apr 2020 by Martin C.
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
assert(isequal(series_sum(3,4),3702))

c = 0×0 empty cell array s = 0×0 empty char array s = '3' c = 1×1 cell array {'3'} s = 0×0 empty char array s = '3' s = '33' c = 1×2 cell array {'3'} {'33'} s = 0×0 empty char array s = '3' s = '33' s = '333' c = 1×3 cell array {'3'} {'33'} {'333'} s = 0×0 empty char array s = '3' s = '33' s = '333' s = '3333' c = 1×4 cell array {'3'} {'33'} {'333'} {'3333'} y = 3702

2   Pass
assert(isequal(series_sum(2,15),246913580246910))

c = 0×0 empty cell array s = 0×0 empty char array s = '2' c = 1×1 cell array {'2'} s = 0×0 empty char array s = '2' s = '22' c = 1×2 cell array {'2'} {'22'} s = 0×0 empty char array s = '2' s = '22' s = '222' c = 1×3 cell array {'2'} {'22'} {'222'} s = 0×0 empty char array s = '2' s = '22' s = '222' s = '2222' c = 1×4 cell array {'2'} {'22'} {'222'} {'2222'} s = 0×0 empty char array s = '2' s = '22' s = '222' s = '2222' s = '22222' c = 1×5 cell array {'2'} {'22'} {'222'} {'2222'} {'22222'} s = 0×0 empty char array s = '2' s = '22' s = '222' s = '2222' s = '22222' s = '222222' c = 1×6 cell array {'2'} {'22'} {'222'} {'2222'} {'22222'} {'222222'} s = 0×0 empty char array s = '2' s = '22' s = '222' s = '2222' s = '22222' s = '222222' s = '2222222' c = 1×7 cell array {'2'} {'22'} {'222'} {'2222'} {'22222'} {'222222'} {'2222222'} s = 0×0 empty char array s = '2' s = '22' s = '222' s = '2222' s = '22222' s = '222222' s = '2222222' s = '22222222' c = 1×8 cell array {'2'} {'22'} {'222'} {'2222'} {'22222'} {'222222'} {'2222222'} {'22222222'} s = 0×0 empty char array s = '2' s = '22' s = '222' s = '2222' s = '22222' s = '222222' s = '2222222' s = '22222222' s = '222222222' c = 1×9 cell array {'2'} {'22'} {'222'} {'2222'} {'22222'} {'222222'} {'2222222'} {'22222222'} {'222222222'} s = 0×0 empty char array s = '2' s = '22' s = '222' s = '2222' s = '22222' s = '222222' s = '2222222' s = '22222222' s = '222222222' s = '2222222222' c = 1×10 cell array {'2'} {'22'} {'222'} {'2222'} {'22222'} {'222222'} {'2222222'} {'22222222'} {'222222222'} {'2222222222'} s = 0×0 empty char array s = '2' s = '22' s = '222' s = '2222' s = '22222' s = '222222' s = '2222222' s = '22222222' s = '222222222' s = '2222222222' s = '22222222222' c = 1×11 cell array {'2'} {'22'} {'222'} {'2222'} {'22222'} {'222222'} {'2222222'} {'22222222'} {'222222222'} {'2222222222'} {'22222222222'} s = 0×0 empty char array s = '2' s = '22' s = '222' s = '2222' s = '22222' s = '222222' s = '2222222' s = '22222222' s = '222222222' s = '2222222222' s = '22222222222' s = '222222222222' c = 1×12 cell array {'2'} {'22'} {'222'} {'2222'} {'22222'} {'222222'} {'2222222'} {'22222222'} {'222222222'} {'2222222222'} {'22222222222'} {'222222222222'} s = 0×0 empty char array s = '2' s = '22' s = '222' s = '2222' s = '22222' s = '222222' s = '2222222' s = '22222222' s = '222222222' s = '2222222222' s = '22222222222' s = '222222222222' s = '2222222222222' c = 1×13 cell array Columns 1 through 12 {'2'} {'22'} {'222'} {'2222'} {'22222'} {'222222'} {'2222222'} {'22222222'} {'222222222'} {'2222222222'} {'22222222222'} {'222222222222'} Column 13 {'2222222222222'} s = 0×0 empty char array s = '2' s = '22' s = '222' s = '2222' s = '22222' s = '222222' s = '2222222' s = '22222222' s = '222222222' s = '2222222222' s = '22222222222' s = '222222222222' s = '2222222222222' s = '22222222222222' c = 1×14 cell array Columns 1 through 12 {'2'} {'22'} {'222'} {'2222'} {'22222'} {'222222'} {'2222222'} {'22222222'} {'222222222'} {'2222222222'} {'22222222222'} {'222222222222'} Columns 13 through 14 {'2222222222222'} {'22222222222222'} s = 0×0 empty char array s = '2' s = '22' s = '222' s = '2222' s = '22222' s = '222222' s = '2222222' s = '22222222' s = '222222222' s = '2222222222' s = '22222222222' s = '222222222222' s = '2222222222222' s = '22222222222222' s = '222222222222222' c = 1×15 cell array Columns 1 through 12 {'2'} {'22'} {'222'} {'2222'} {'22222'} {'222222'} {'2222222'} {'22222222'} {'222222222'} {'2222222222'} {'22222222222'} {'222222222222'} Columns 13 through 15 {'2222222222222'} {'22222222222222'} {'222222222222222'} y = 2.4691e+14

3   Pass
assert(isequal(series_sum(9,9),1111111101))

c = 0×0 empty cell array s = 0×0 empty char array s = '9' c = 1×1 cell array {'9'} s = 0×0 empty char array s = '9' s = '99' c = 1×2 cell array {'9'} {'99'} s = 0×0 empty char array s = '9' s = '99' s = '999' c = 1×3 cell array {'9'} {'99'} {'999'} s = 0×0 empty char array s = '9' s = '99' s = '999' s = '9999' c = 1×4 cell array {'9'} {'99'} {'999'} {'9999'} s = 0×0 empty char array s = '9' s = '99' s = '999' s = '9999' s = '99999' c = 1×5 cell array {'9'} {'99'} {'999'} {'9999'} {'99999'} s = 0×0 empty char array s = '9' s = '99' s = '999' s = '9999' s = '99999' s = '999999' c = 1×6 cell array {'9'} {'99'} {'999'} {'9999'} {'99999'} {'999999'} s = 0×0 empty char array s = '9' s = '99' s = '999' s = '9999' s = '99999' s = '999999' s = '9999999' c = 1×7 cell array {'9'} {'99'} {'999'} {'9999'} {'99999'} {'999999'} {'9999999'} s = 0×0 empty char array s = '9' s = '99' s = '999' s = '9999' s = '99999' s = '999999' s = '9999999' s = '99999999' c = 1×8 cell array {'9'} {'99'} {'999'} {'9999'} {'99999'} {'999999'} {'9999999'} {'99999999'} s = 0×0 empty char array s = '9' s = '99' s = '999' s = '9999' s = '99999' s = '999999' s = '9999999' s = '99999999' s = '999999999' c = 1×9 cell array {'9'} {'99'} {'999'} {'9999'} {'99999'} {'999999'} {'9999999'} {'99999999'} {'999999999'} y = 1.1111e+09

4   Pass
assert(isequal(series_sum(1,12),123456790122))

c = 0×0 empty cell array s = 0×0 empty char array s = '1' c = 1×1 cell array {'1'} s = 0×0 empty char array s = '1' s = '11' c = 1×2 cell array {'1'} {'11'} s = 0×0 empty char array s = '1' s = '11' s = '111' c = 1×3 cell array {'1'} {'11'} {'111'} s = 0×0 empty char array s = '1' s = '11' s = '111' s = '1111' c = 1×4 cell array {'1'} {'11'} {'111'} {'1111'} s = 0×0 empty char array s = '1' s = '11' s = '111' s = '1111' s = '11111' c = 1×5 cell array {'1'} {'11'} {'111'} {'1111'} {'11111'} s = 0×0 empty char array s = '1' s = '11' s = '111' s = '1111' s = '11111' s = '111111' c = 1×6 cell array {'1'} {'11'} {'111'} {'1111'} {'11111'} {'111111'} s = 0×0 empty char array s = '1' s = '11' s = '111' s = '1111' s = '11111' s = '111111' s = '1111111' c = 1×7 cell array {'1'} {'11'} {'111'} {'1111'} {'11111'} {'111111'} {'1111111'} s = 0×0 empty char array s = '1' s = '11' s = '111' s = '1111' s = '11111' s = '111111' s = '1111111' s = '11111111' c = 1×8 cell array {'1'} {'11'} {'111'} {'1111'} {'11111'} {'111111'} {'1111111'} {'11111111'} s = 0×0 empty char array s = '1' s = '11' s = '111' s = '1111' s = '11111' s = '111111' s = '1111111' s = '11111111' s = '111111111' c = 1×9 cell array {'1'} {'11'} {'111'} {'1111'} {'11111'} {'111111'} {'1111111'} {'11111111'} {'111111111'} s = 0×0 empty char array s = '1' s = '11' s = '111' s = '1111' s = '11111' s = '111111' s = '1111111' s = '11111111' s = '111111111' s = '1111111111' c = 1×10 cell array {'1'} {'11'} {'111'} {'1111'} {'11111'} {'111111'} {'1111111'} {'11111111'} {'111111111'} {'1111111111'} s = 0×0 empty char array s = '1' s = '11' s = '111' s = '1111' s = '11111' s = '111111' s = '1111111' s = '11111111' s = '111111111' s = '1111111111' s = '11111111111' c = 1×11 cell array {'1'} {'11'} {'111'} {'1111'} {'11111'} {'111111'} {'1111111'} {'11111111'} {'111111111'} {'1111111111'} {'11111111111'} s = 0×0 empty char array s = '1' s = '11' s = '111' s = '1111' s = '11111' s = '111111' s = '1111111' s = '11111111' s = '111111111' s = '1111111111' s = '11111111111' s = '111111111111' c = 1×12 cell array {'1'} {'11'} {'111'} {'1111'} {'11111'} {'111111'} {'1111111'} {'11111111'} {'111111111'} {'1111111111'} {'11111111111'} {'111111111111'} y = 1.2346e+11

5   Pass
assert(isequal(series_sum(5,5),61725))

c = 0×0 empty cell array s = 0×0 empty char array s = '5' c = 1×1 cell array {'5'} s = 0×0 empty char array s = '5' s = '55' c = 1×2 cell array {'5'} {'55'} s = 0×0 empty char array s = '5' s = '55' s = '555' c = 1×3 cell array {'5'} {'55'} {'555'} s = 0×0 empty char array s = '5' s = '55' s = '555' s = '5555' c = 1×4 cell array {'5'} {'55'} {'555'} {'5555'} s = 0×0 empty char array s = '5' s = '55' s = '555' s = '5555' s = '55555' c = 1×5 cell array {'5'} {'55'} {'555'} {'5555'} {'55555'} y = 61725

### Community Treasure Hunt

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

Start Hunting!