Most credit cards and debit cards contain a special last digit in their series of digits that make up the primary account number (PAN). This last digit is a check sum digit and provides a special function. The identity of the digit is determined by the preceding digits in the PAN. There are frequently 15-18 preceding digits in an average credit or debit card. The check sum digit is not a security feature but instead acts to reduce the error rate of copying down the incorrect digits making up a PAN. The check sum digit uses the preceding digits and a special algorithm, or equation, called the Luhn algorithm.
The Luhn algorithm was developed in 1954 by computer scientist Hans Luhn - hence the algorithm’s name, although it is also known as the modulus 10 or mod 10 algorithm. The checksum formula uses all of the PAN digits, except the checksum digit and generates a digit from 0-9. This digit then becomes the final number in the PAN.
The algorithm is not particularly complex but serves to reduce the accidental use of incorrect PANs. The calculation starts with the final number, before the checksum digit, which hasn’t been calculated yet. All digits in odd positions are multiplied by 2. If the product of the multiplication is equal to or greater than 10, then that product is replaced with the digit that is the sum of the 2 digits making up the number 10 or greater. For example, assume that digit #3 in the PAN is the number 7; to make the calculation, 7 is multiplied by 2 to generate 14; 14 is then transformed to 1+4 = 5; so 5 is the digit representing the digit in position #3 of the PAN.