Luhn algorithm [WiKi]

1. Compute the sum of all digits on odd places. | |||||||||||||||||

= | |||||||||||||||||

2. Replace the digits on even places by the formula: 0=>0, 1=>2, 2=>4, 3=>6, 4=>8, 5=>1, 6=>3, 7=>5, 8=>7, 9=>9 and summarize them. | |||||||||||||||||

= | |||||||||||||||||

3. Summarize the two results. | + | = | |||||||||||||||

4. In case the sum of digits ends in 0, 0 is the check digit. Otherwise, the checksum is equal to the number that needs to be added to the result to get the next highest "round" number. | |||||||||||||||||

Check digit | + | = | |||||||||||||||