Credit Card Check Digit

A Credit Card number usually consist of 3 parts:

  • Issuer ID (left most 6 digits)
  • Account Number (9 digits)
  • Check Digit (right most 1 digit)

All valid credit cards fulfill a validation check called “Luhn Check”.  The algorithm of Luhn Check is simple:

  1. Double each odd position digit of the credit card number.
  2. If the resulting number is 2 digits, add the two digits.
  3. Replace all odd position digit with the newly calculated digit.
  4. Add up all 16 digits and divide by 10.
  5. If the total can be perfectly divided by 10, it satisfy the “Luhn Check”.

Example:

  1. Sample credit card number (Visa):  4111 1111 1111 1111
  2. Double the odd position digits:  8121 2121 2121 2121
  3. Add up all 16 digits: 8+1+2+1+2+1+2+1+2+1+2+1+2+1+2+1= 30
  4. 30 can be perfectly divided by 10, so the credit card number fulfills the “Luhn Check”.

Example 2:

  1. Sample credit card number (Master Card):  5500 0000 0000 0004
  2. Double the odd position digits (the first digit is 10=>1+0=>1):  1500 0000 0000 0004
  3. Add up all 16 digits: 1+5+0+0+0+0+0+0+0+0+0+0+0+0+0+4= 10
  4. 10 can be perfectly divided by 10, so the credit card number fulfills the “Luhn Check”.

For a more detail explanation, see http://www.thetaoofmakingmoney.com/2007/04/12/324.html

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: