HTML and CSS Reference

In-Depth Information

The Lunh Formula.
The credit card number can be subjected to an additional math-

ematical test, called the Lunh formula, which it must pass to be valid. The following

steps are required to validate the primary account number:

Step 1:
Double the value of every other digit starting with the next-to-rightmost

digit.

Step 2:
If any of the resulting values has more than two digits, then its digits must

be added together to produce a single digit.

Step 3:
Add the sum of all the digits
not
doubled in Step 1 to the sum of the digits

transformed from Steps 1 and 2.

Step 4:
If the result is exactly divisible by 10 (i.e., if the result ends in a zero, 30, 40,

50, etc.), then the number is valid—providing of course that it's of the cor-

rect length and bears a correct prefix for that type of card.

For example, to validate the primary account number
49927398716:

Step 1:
Starting from the next to the right-most digit, multiply every other number

by 2 (the number in bold text).

4
9
9
2
7
3
9
8
7
1
6

9x2 2x2 3x2 8x2 1x2

18

4

6

16

2

Step 2:
If any numbers resulting from Step 1 have more than one digit, add those

numbers together.

(1+8) (1+6)

————————————

9

7

Step 3:
Add up the top row of numbers that were not doubled (not in bold) to the

bottom row of numbers after Step 2 was finished. Bottom numbers are in

parentheses.

4+(9)+9+(4)+7+(6)+9+(7)+7+(2)+6

Step 4:
If the result of Step 3 is divisible exactly by 10 (i.e., leaves no remainder),

the card is valid. The result of Step 3 is 70. The card number is valid if the

card type is valid, as long as the length of numbers entered is valid, and it

has the correct prefix for that type of card.