Skip to content

Instantly share code, notes, and snippets.

@tomharris
Forked from anolson/instructions.md
Last active March 12, 2020 16:57
Show Gist options
  • Save tomharris/bc9a942bcd25e029e746 to your computer and use it in GitHub Desktop.
Save tomharris/bc9a942bcd25e029e746 to your computer and use it in GitHub Desktop.

Luhn Checksum

Implement a Ruby program that outputs the validity of a number by applying the Luhn Checksum.

http://en.wikipedia.org/wiki/Luhn_algorithm

Please treat this as you would any other task you'd encounter during your daily work. This will show us how currently code, and not how you coded 6, 12 or 18 months ago. Your code should also be suitably tested. Also, please do not feel that you need to spend a great deal of time working on a solution.

There are many solutions and code snippets online to do a Luhn Checksum. Please resist using those.

Input:

The program should accept a single number to validate.

Output:

The program should output the input along with the validity of the number.

Examples:

With an input of 79927398713 the output should be:

79927398713 is valid.

With an input of 79927398710 the output should be:

79927398710 is not valid.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment