Use DataGeneratorTools - Luhn Digit Calculator to calculate the luhn check digit for any credit or debit card.

The Luhn algorithm (“modulus 10” or “mod 10” algorithm, Luhn formula) is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers (PAN) or IMEI numbers. The algorithm is specified in ISO/IEC 7812-1 and it was designed to protect against accidental errors. The Luhn algorithm 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).

- From the rightmost digit, which is the check digit, moving left, double the value of every second digit;
- If the product of this doubling operation is greater than 9, then sum the digits of the products or alternatively subtract 9 from the product.
- Take the sum of all the digits.
- Multiply by 9.
- The last digit is the check digit.

PAN |
3 | 7 | 1 | 4 | 4 | 9 | 6 | 3 | 5 | 3 | 9 | 8 | 4 | 3 | X |

Double values |
3 | 14 |
1 | 8 |
4 | 18 |
6 | 6 |
5 | 6 |
9 | 16 |
4 | 6 |
X |

Sum digits |
3 | 5 |
1 | 8 |
4 | 9 |
6 | 6 |
5 | 6 |
9 | 7 |
4 | 6 |
X |