Cody

Problem 45490. Luhn's Algorithm

Solution 2918452

Submitted on 6 Sep 2020 by Rafael S.T. Vieira
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 = '0'; assert(isequal(luhn(x),'00'));

2   Pass
x = '1'; assert(isequal(luhn(x),'12'));

3   Pass
x = '5'; assert(isequal(luhn(x),'51'));

4   Pass
x = '9'; assert(isequal(luhn(x),'99'));

5   Pass
x = '10'; assert(isequal(luhn(x),'101'));

6   Pass
x = '80'; assert(isequal(luhn(x),'808'));

7   Pass
x = '080'; assert(isequal(luhn(x),'0808'));

8   Pass
x = '180'; assert(isequal(luhn(x),'1800'));

9   Pass
x = '1234567890'; assert(isequal(luhn(x),'12345678907'));

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!