Encyclopedia > Luhn formula

  Article Content

Luhn formula

The Luhn formula, also known as the "modulus 10" or "mod 10" algorithm, is a simple, public domain checksum formula used to validate a variety of account numbers, such as credit card numbers and Canadian Social Insurance Numbers. Much of its notoriety comes from credit card companies' adoption of it shortly after its creation in the late 1960s.

The formula generates a check digit, which is usually appended to a partial account number to generate the full account number. This account number must pass the following algorithm (and the check digit chosen and placed so that the full account number will):

  1. Starting with the second to last digit and moving left, double the value of all the alternating digits. For any digits that thus become 10 or more, add their digits together. For example, 1111 becomes 2121, while 8763 becomes 7733 (from (1+6)7(1+2)3).
  2. Add all these digits together. For example, 1111 becomes 2121, then 2+1+2+1 is 6; while 8763 becomes 7733, then 7+7+3+3 is 20.
  3. If the total ends in 0 (put another way, if the total modulus 10 is 0), then the number is valid according to the LUHN formula, else it is not valid. So, 1111 is not valid (as shown above, it comes out to 6), while 8763 is valid (as shown above, it comes out to 20).

In the two examples above, if a check digit was to be added to the front of these numbers, then 4 might be added to 1111 to make 41111, while 0 would be added to 8763 to make 08763. It is usually the case that check digits are added to the end, although this requires a simple modification to the algorithm to determine an ending check digit given the rest of the account number.



All Wikipedia text is available under the terms of the GNU Free Documentation License

 
  Search Encyclopedia

Search over one million articles, find something about almost anything!
 
 
  
  Featured Article
Holtsville, New York

... the median income for a family is $71,784. Males have a median income of $50,361 versus $31,709 for females. The per capita income for the town is $24,031. 3.6% of the ...

 
 
 
This page was created in 32.9 ms