Luhn algorithm [WiKi]

1. Digits of the checked sequentially numbered from right to left. | |||||||||||||||||

2. Digits, which turned out to odd places remain unchanged. 3. The digits that standing on even places, multiplied by 2. | |||||||||||||||||

4. If the result of this multiplication occurs a number greater than 9, it is replaced by the sum of the digits of the result of multiplying - single digit. | |||||||||||||||||

5. All calculated digits are summarized. If the sum is a multiple of 10, the account number is possibly valid. | |||||||||||||||||