Problem 45490. Luhn's Algorithm
Luhn's Algorithm is used as a checksum for credit card numbers or similar identifiers. It can detect single-digit changes and swapped digits. It consists of four steps:
- Double every second digit (starting with the last one).
 - If a digit exceeds 9 due to the doubling, subtract 9.
 - Add all the digits.
 - Append the last digit of the sum to the original number.
 
More information can be found on https://en.wikipedia.org/wiki/Luhn_algorithm or in ISO/IEC 7812-1.
Your function takes the original numbers as a character vector, and it has to return a character vector that includes the checksum.
Solution Stats
Solution Comments
Show commentsProblem Recent Solvers20
Suggested Problems
- 
         
Who knows the last digit of pi?
679 Solvers
 - 
         
Replace all zeros and NaNs in a matrix with the string 'error'
101 Solvers
 - 
         
         
9693 Solvers
 - 
         
Change the sign of even index entries of the reversed vector
602 Solvers
 - 
         
Rounding off numbers to n decimals
5242 Solvers
 
More from this Author1
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!