The Luhn algorithm was developed by German computer scientist Hans Peter Luhn in 1954. It calculates simple checksum formula used to validate identification numbers such as credit card numbers. The algorithm was designed to protect against accidental errors, such as a digit mistyping. It will detect any single-digit error, as well as almost all transpositions of adjacent digits. It will not, however, detect transposition of the two-digit sequence 09 to 90 (or vice versa).
The calculator below gives Luhn checksum of the given digit sequence. The sequence is considered valid if the checksum mod 10 equals to zero. It also gives the next check digit to be appended at the end of source sequence to form valid number according Luhn algorithm.
The formula is quite simple: to calculate Luhn checksum you need to sum all odd digits ( calculating from right to left, so last digit is considered N1) plus sum of all even digits multiplied by 2, if the product of multiplication is greater than 9 you must subtract 9. If the last digit of the ckecksum is zero, the whole sequence is valid.
To produce validation digit we can simply append "0" to source sequence and calculate Luhn checksum again. If last digit of the obtained checksum is zero then the validation digit is also zero, otherwise validation digit can be obtained by subtracting last checksum digit from 10.