Share |
The truths they don't want you to read....

Thursday, September 20, 2007

Credit card numbers

Ever wondered how your credit card number is formed, and how it is quickly checked by the card machines?

Today I discovered the Lunh algorithm which defines each card as being valid.

Put simply, the algorithm is "For a card with an even number of digits, double every odd numbered digit and subtract 9 if the product is greater than 9. Add up all the even digits as well as the doubled-odd digits, and the result must be a multiple of 10 or it's not a valid card. If the card has an odd number of digits, perform the same addition doubling the even numbered digits instead."

The simple worked examples in the above link explain clearly how the numbers work and what they mean.

ps Don't try this in binary.

No comments: