Cody

Problem 2008. Number Persistence

Solution 451170

Submitted on 6 Jun 2014 by Coralie
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 = 77; y_correct =4 assert(isequal(persistence(x),y_correct ))

y_correct = 4 ans = 7 7 ans = 4 9 N = 1 ans = 3 6 N = 2 ans = 1 8 N = 3 ans = 8 N = 4

2   Pass
%% x = 976; y_correct =5 assert(isequal(persistence(x),y_correct ))

y_correct = 5 ans = 9 7 6 ans = 3 7 8 N = 1 ans = 1 6 8 N = 2 ans = 4 8 N = 3 ans = 3 2 N = 4 ans = 6 N = 5

3   Pass
%% x =88869; y_correct =7 assert(isequal(persistence(x),y_correct ))

y_correct = 7 ans = 8 8 8 6 9 ans = 2 7 6 4 8 N = 1 ans = 2 6 8 8 N = 2 ans = 7 6 8 N = 3 ans = 3 3 6 N = 4 ans = 5 4 N = 5 ans = 2 0 N = 6 ans = 0 N = 7

Suggested Problems

More from this Author12

Community Treasure Hunt

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

Start Hunting!