## The Logic Behind a 16 Digit Credit Card Number

Rated 4.5/5 based on 11 customer reviews
Normal Mode Dark Mode

# The Logic Behind a 16 Digit Credit Card Number

Aamir Ansari
Blog
31st Oct, 2018

A credit card or a debit card has a unique 16 digit number that everyone is aware of. But, do you know these numbers are not a just random string of numbers rather it reveals a lot more information than you think.

Ever wondered what does numbers on credit card actually represents? How that 16 digits identify the bank and the account from which your money needs to be paid to the billing party?

A sample credit card

Let’s dive into these 16 digits that we just see a string of random numbers and is often wondering what numbers on credit card mean.

##### Understanding numbers on Credit Card

Major Identity Identifier (MII)The first digit of the card represents the category of industry which issued your credit card. This is known as “Major Industry Identifier” short for MII.

Following is the list of Major Identity Identifier MII:

1. ISO And Other Industries,
2. Airlines,
3. Airlines And Other Industries,
4. Travels And Entertainment American Express Or Food Club,
5. Banking And Finance VISA,
6. Banking And Finance Mastercard,
7. Banking And Merchandising,
8. Petroleum,
9. Telecommunications And Other Industries,
10. National Assignment

Issuer Identification Number (IIN)The first six digits of the credit card number are known as the Issuer Identification Number short for IIN and this is to identify the institution that issued the card.

The series followed by VISA cards starts from 4xx while that of Mastercard starts from 51–55 as the prefix.

Account Number associated with Credit CardTaking away the first 6 identifier digits, the following 6 to 9 digits constitutes unique bank account number. Now, this is not exactly the bank account number of a customer but the account number assigned to your credit account.

Check Digit: And lastly, one last digit known as the “check digit” which is generated in such a way as to satisfy a certain condition.

##### Here is the logic behind the condition that must be satisfied:

Step 1: Let’s consider the card number as 1802909582961827

Step 2: As of now, just consider first 15 digits i.e., 180290958296182|7

Step 3: Now beginning from the left, start with the first number, take every second number and multiply it by 2 as shown here:

Starting from the first i.e., 1 and taking every second number, we will get the following numbers: 1 0 9 9 8 9 1 2

1 * 2 = 2

0 * 2 = 0

9 * 2 = 18

9 * 2 = 18

8 * 2 = 16

9 * 2 = 18

1 * 2 = 2

2 * 2 = 4

Step 4: Sum up the digits if the multiplication results in a 2 digit number. i.e., 18 => 1 + 8 = 9

This will give us all the result in a single digit number.

So, we get : 2,0,9,9,7,9,2,4

Step 5: Now, Sum up all the single digits and all the digits left in the card number.

i.e., 2+0+9+9+7+9+2+4 + 8+2+0+5+2+6+8 = 73

Add the sum together. Now, what must be added to the sum obtained so that it is divisible by 10? In this case, it is 7

So, 73+ 7 = 80 which is divisible by 10.

This last digit so obtained is called as Checksum digit.

That’s the logic behind credit/debit card numbers.

##### How many digits in a Credit Card Number?

Now, the number of digits in a credit card number varies with the issuing authority.

##### Following is the list of some issuing authorities along with their card length: Issuing Authority with Card Length (Description)

VISA and VISA Electron: 13 or 16 digits

Mastercard: 16 digits

Discover: 16 digits

American Express: 15 digits

Diners Club Card: 14 digits (including International and Blanche)

Maestro Cards: 12 to 19 (multi-national debit card)

Laser: 16 to 19 (Ireland)

Switch: 16, 18 or 19 (United Kingdom)

Solo: 16, 18 or 19 (United Kingdom)

JCB: 15 or 16 (Japan Credit Bureau: Japan)

China UnionPay: 16 (People’s Republic of China: China)

##### What checks will we perform on your number?

We perform some checks on your number and explain what each part of it means.

##### That being said, we’ll show you results for:
• Luhn algorithm check
• Major Industry Identifier
• Issuer Identification Number

##### Card Verification Number :

There is another number which is usually behind the card usually of 3 to 4 digits and is known by various names like CVVs, CVV2s called card verification value, and card security code (CSC). These are all calculated using the CVV algorithm.

The codes have different names as per issuing authority:

Code issued by issuing authority

They are required by payment systems such as MasterCard and Visa to authenticate their credit or debit cards.

There are several types of security codes:

• The first code is encoded on track 2 of the magnetic stripe of the card and used for card present transactions called CVC1 or CVV1,
• The second code is often sought by merchants for card occurring by fax, mail, or Internet telephone, it is called CVV2 or CVC2.
• The card security code is typically the last three or four digits printed.
##### The logic behind CVV generation:

To generate or calculate the 3-digit CVV, the algorithm requires is:

Primary Account Number (PAN), a 4-digit Expiration Date, a pair of DES keys (CVKs), and a 3-digit Service Code. This algorithm is only known to the bank and not for any person or organization.

##### Tips to keep your Card and PIN safe:
2. Safeguard your card as though it was a cash.
3. Memorize your PIN. Never write it down.
4. Do not forget to receive your card back from the salesclerk or waiter when you use it.
5. Torn the receipts that contain the full account number if you do not need to keep them.
6. Make sure to review your account statements as soon as you receive them so that you are confirmed that all the transactions are yours.
7. Make a list of your credit card numbers and customer service phone numbers and store it in a safe place, probably encrypted software or some hard safe place.

This way it will be easier for you to call to cancel the cards if your purse or wallet is lost or stolen.

##### What NEXT?

In the next part of this series, we will see the implementation of the code that will generate valid credit/debit card numbers along with their Issuing Authority and Account Number.

Hope you have found this post useful. Please don’t forget to like and share with your friends because sharing is caring. :)

### Aamir Ansari

Blog Author

Mohd Amir Ansari is a software engineer and founder of techiners.in. He is Microsoft Certified Professional specialization in Programming in HTML5 with JavaScript and CSS3. Professionally a software engineer, teacher by passion, blogger by chance, and a poet by hobby. In my spare time, I love to write about technology, programming, mathematics, poetry.

### Mohd faizan

13 November 2018 at 10:00am
Help full information thank you sir

### Shahbaz

13 November 2018 at 10:01am
It was a good research sir..... Waiting for next part

### Salman Rizvi

13 November 2018 at 10:01am
Dear Amir, It is great to know about these things. It is good content. Keep writing. Best of luck My Brother