Cody

Problem 2300. Natural numbers in string form

Solution 3430918

Submitted on 27 Oct 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
x = 1; y_correct = {'1'}; assert(isequal(naturalnumbers(x),y_correct))

v = 1 v = 49

2   Fail
x = 11; y_correct = {'1','2','3','4','5','6','7','8','9','10','11'}; assert(isequal(naturalnumbers(x),y_correct))

v = 1 2 3 4 5 6 7 8 9 10 11 v = 49 2 3 4 5 6 7 8 9 10 11 v = 49 50 3 4 5 6 7 8 9 10 11 v = 49 50 51 4 5 6 7 8 9 10 11 v = 49 50 51 52 5 6 7 8 9 10 11 v = 49 50 51 52 53 6 7 8 9 10 11 v = 49 50 51 52 53 54 7 8 9 10 11 v = 49 50 51 52 53 54 55 8 9 10 11 v = 49 50 51 52 53 54 55 56 9 10 11 v = 49 50 51 52 53 54 55 56 57 10 11

Unable to perform assignment because the left and right sides have a different number of elements. Error in naturalnumbers (line 4) v(i)=num2str(v(i)) Error in Test2 (line 3) assert(isequal(naturalnumbers(x),y_correct))

Suggested Problems

More from this Author1

Community Treasure Hunt

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

Start Hunting!