If you thought the sprawl of 16 numbers across the front of your credit was randomly generated, think again: like any good string of numbers, an algorithm was involved in its creation.
In fact, the first couple of numbers relate to the kind of card it is: Visas start with a 4, Mastercards a 5, Amex a 34 or 37. But there's far more to it than that. In fact, we have a chap called Hans Peter Luhn to thank. Data Genetics explains:
You don’t select this last digit, it is deterministic. The exact mathematic formula for its generation was invented by Hans Peter Luhn, an engineer at IBM in 1954. Originally patented, the algorithm is now in the public domain and a Worldwide standard ISO/IEC 7812-1
Obviously, with just a single check digit, not all errors can be detected (there’s a one in 10 chance of a random number having the correct check digit), but the Luhn algorithm is clever in that it detects any single error (getting a single digit wrong), such as swapping the 9 with a 6 in the above example. It also detects almost all* pair-wise switching of two adjacent numbers. These errors are typical common errors people make when transcribing card numbers, so the check digit does a good thing.
An added side benefit is that, as discussed above, there is only a one in 10 chance that a randomly generated number has the correct check digit. This provides a small amount of protection from hackers or poorly educated crooks who might attempt to randomly generate and guess credit card numbers.
So there you have it: more thought went into your credit card number than you probably ever imagined. If you want more detail, read the Data Genetics article; it makes for interesting reading. [Data Genetics via Neatorama]