Skip to content

erinekim/luhn_algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

LUHN ALGORITHM

The Luhn Algorithm

Implement the Luhn Algorithm which is used to help validate a variety of identification numbers such as credit card numbers.

How to implement:

  1. If there is an even number of digits, double every other digit starting with the first; if there is an odd number of digits, double every other digit starting with the second.

  2. If a resulting doubled number is greater than 9, replace it with either the sum of its own digits or 9 subtracted from it (Example: 18 = 1+8 = 9)

  3. Take the sum of all the final digits.

  4. Finally, take that sum and divide it by 10. If the remainder equals 0, the original credit card number is valid.

About

Implement the Luhn Algorithm to help validate a credit card number

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages