How to check validity of credit card numbers (Luhn’s algorithm)

david

Credit or Debit cards are issued by banks (and also by other institutions) to carry out easy and wide scale transactions with ease. Each of these cards has a unique Card Number associated with it. This is the number that is used to validate the card at the time of carrying out transactions.

You don’t need a complex algorithm to check the validity of your debit or credit card. With the help of a simple calculation, you can verify the validity of your card (or any card). In order to validate a card, you first need to understand how credit / debit card numbers are assigned.

What do those numbers mean?

Ever wondered what those numbers on your credit card mean? Your card number is not randomly allocated. Rather, they follow some regular pattern which helps us to find card related information. Here is how the numbers are generated.

The first six digits of the card tell us about the card’s issuer and is known as the Issuer Identification Number (IIN). Cards can be looked up by this number. Given below are some of the examples of IIN.

Visa: 4xxxxx
Mastercard: 51xxxx-55xxxx
Discover: 6011xx, 644xxx, 65xxxx
American Express (Amex): 34xxxx, 37xxxx

The seventh and following digits resemble cardholder’s account number.

The final digit is the checksum. This is the digit used to validate cards using Luhn’s algorithm.

How to check the validity of your card?

You can check whether your credit or debit card is really valid or not by following the steps mentioned below. Take, for example, the card number: 4417 1234 5678 9113

Step 1: Start from the right side and separate all the even and odd digits.

4417 1234 5678 9113

41 13 57 91                          47 24 68 13

Step 2: Double all the digits in the first set

82 26 (10)(14) (18)2        

Step 3: Add all double digit numbers as the sum of their digits.

82 26 (1+0)(1+4)  (1+8)                             

82 26 15 9                                                        

Step 4: Add all the odd digits (those that have not been doubled) to the even (doubled) digits.

8 + 2 + 2 + 6 + 1 + 5 + 9 + 2 + 4 + 7 + 2 + 4 +  6 + 8 + 1 + 3 = 70

Step 5: Final result – If the final result is divisible by 10, the card number is valid.

70/10=7 (The number is valid)

Tags:

Share your thoughts