You are on page 1of 5

ANATOMY OF CREDIT

CARD NUMBERS
Validation by Luhn Algorithm

Submitted by:
Haris Karim

MARCH 11, 2016


CAS SCHOOL
Project Submitted for Application of mathematics

Anatomy of Credit Card Numbers


Introduction
Mathematics is the queen of science and the language of nature. Its importance should be
clear to any reasonable person. It is easy however to diminish the value of certain areas of
research because theyre currently thought as having little practical use. Evolutionary needs
brought our mind to prefer knowledge that can be employed for the solution of specific
problems in the real world, rather than deeply abstract ones. It is an understandable that there
are useful fields of math and useless ones, based on the perception of their applied or
theoretical nature. But its still a misconception. Each theorem and discovery is a little piece
of a larger puzzle. Discoveries and mathematical ideas that are perceived as useful today
because theyre applicable to engineering, for example, were at a certain point in time
considered absolutely abstract and useless. Therefore Mathematics matters; all of it.
Modulo Algebra at one time was considered to be abstract and useless branch of mathematics
but today it is an important tool used for Cryptography and other check sum validation
techniques used to validate the syntax of various formats such Credit Card Numbers, Account
Numbers, Social Security numbers, etc.
The part of the Modulo Algebra use to validate Credit Card number is known as Luhn
algorithm or Luhn formula, also known as the "modulus 10" or "mod 10" algorithm. 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.

Methodology
The number must pass the following test:

From the rightmost digit, which is the check digit, moving left, double the value of
every second digit; if the product of this doubling operation is greater than 9 (e.g., 8
2 = 16), then sum the digits of the products (e.g., 16: 1 + 6 = 7, 18: 1 + 8 = 9) or
alternatively subtract 9 from the product (e.g., 16: 16 - 9 = 7, 18: 18 - 9 = 9).

Take the sum of all the digits.

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.

Structure
MII Digit
The first digit of your credit card number is the Major Industry Identifier (MII), which
represents the category of entity which issued your credit card. Different MII digits represent
the following issuer categories:

For example, American Express, Diner's Club, and Carte Blanche are in the travel and
entertainment category, VISA, MasterCard, and Discover are in the banking and financial
category, and SUN Oil and Exxon are in the petroleum category.
Issuer Identifier
The first 6 digits of your credit card number (including the initial MII digit) form the issuer
identifier. This means that the total number of possible issuers is a million (10 raised to the
sixth power, or 1,000,000). Some of the better known issuer identifiers are listed in the
following table:

The first digit is the MII digit, then the next three digits of the issuer identifier are the 3-digit
country codes defined in ISO 3166, and the remaining final two digits of the issuer identifier
can be defined by the national standards body of the specified country in whatever way it
wishes.
Check Digit
The final digit of any credit card number is a check digit, akin to a checksum. The algorithm
used to arrive at the proper check digit is called the Luhn algorithm, after IBM scientist Hans
Peter Luhn (1896-1964), who was awarded US Patent 2950048 ("Computer for Verifying
Numbers") for the technique in 1960.
Account Number
Digits 7 to (n - 1) of any credit card number are individual account identifier. The maximum
length of a credit card number is 19 digits. Since the initial 6 digits of a credit card number
are the issuer identifier, and the final digit is the check digit, this means that the maximum
length of the account number field is 19 - 7, or 12 digits. Each issuer therefore has a trillion
(10 raised to the 12th power, or 1,000,000,000,000) possible account numbers.
If we consider the large number of potential customers and usurious interest rates charged by
issuers, there is obviously a lot of money to be made in the credit card industry.

Illustrating Luhn Algorithm on Credit Card Numbers


Example 1
Consider a credit card number 4408 0412 3456 7890
The Major Industry Identifier (MII) is 4 (banking and financial), the issuer identifier is
440804 (a VISA partner), the account number is 123456789, and the check digit is 0.
Let's apply the Luhn check to 4408 0412 3456 7890

The top row is the original number.

In the second row, we multiply alternate digits by 2. Don't multiply the check digit by
2.

In the third row, we force all digits to be less than 10, by subtracting 9 where
necessary.

The bottom row contains the digits to be added together.

If we add all of the digits in the bottom row together, we get 67, which is not a multiple of 10,
and therefore we conclude that the number 4408 0412 3456 7890 is an invalid credit card
number.
Example 2
Consider a second credit card number 4417 1234 5678 9112
The Major Industry Identifier (MII) is 4 (banking and financial), the issuer identifier is
441712 (a VISA partner), the account number is 345678911, and the check digit is 2.
Applying the Luhn check to 4417 1234 5678 9112

If we add all of the digits in the bottom row together, we get 69, which is not a multiple of 10,
and therefore we conclude that the number 4417 1234 5678 9112 is an invalid credit card
number.

Conclusion
By changing the check digit from 0 to 3 in example 1 and from 2 to 3 in example 2, we arrive
at the number 4408 0412 3456 7893 and 4417 1234 5678 9113 respectively, which does pass
the Luhn check, since the sum of the digits in the bottom row would be 70, which is divisible
by 10, this will make both Credit Card Numbers valid from structure perspective.

You might also like