General / Technologies

Credit Card Validation Algorithm (Luhn Algorithm)

Luhn Algorithm is a simple checksum formula used to validate credit card numbers, IMEI numbers etc. This algorithm also known as modulus 10  or mod 10 algorithm. It was created by IBM scientist Hans Peter Luhn.

The formula verifies a number against its included check digit, which is usually appended to a partial account number to generate the full account number. This account number must pass the following test:

  1. From the rightmost digit, which is the check digit, moving left, double the value of every second digit; if product of this doubling operation is greater than 9 (e.g., 7 * 2 = 14).
  2. Sum the digits of the products (e.g., 10: 1 + 0 = 1, 14: 1 + 4 = 5) together with the undoubled digits from the original number.
  3. If the total modulo 10 is equal to 0 (if the total ends in zero) then the number is valid according to the Luhn formula; else it is not valid.

The following picture represents the credit card algorithm clearly.



One thought on “Credit Card Validation Algorithm (Luhn Algorithm)

Leave a Reply

Please log in using one of these methods to post your comment: Logo

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

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s