Cody

Problem 45246. Count digits

Solution 3248313

Submitted on 17 Oct 2020 by Dyuman Joshi
  • Size: 28
  • This is the leading solution.
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 = 13; y_correct = 17; assert(isequal(count_dig(n),y_correct))

ans = 17

2   Pass
n = 1339; y_correct = 4249; assert(isequal(count_dig(n),y_correct))

ans = 4249

3   Pass
n = 0; y_correct = 0; assert(isequal(count_dig(n),y_correct))

ans = 0

4   Pass
n = 299; y_correct = 789; assert(isequal(count_dig(n),y_correct))

ans = 789

5   Pass
n = 10000; y_correct = 38894; assert(isequal(count_dig(n),y_correct)) % n=10000675820025; y_correct = 128898350369253; assert(isequal(count_dig(n),y_correct))

ans = 38894 ans = 1.2890e+14

Suggested Problems

More from this Author149

Community Treasure Hunt

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

Start Hunting!