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:

  1. Double every second digit (starting with the last one).
  2. If a digit exceeds 9 due to the doubling, subtract 9.
  3. Add all the digits.
  4. Append the last digit of the sum to the original number.

More information can be found on 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

38.46% Correct | 61.54% Incorrect
Last Solution submitted on Jun 14, 2020

Problem Recent Solvers10

Suggested Problems

More from this Author1

Problem Tags