What Is the Luhn Algorithm?
The Luhn Algorithm—also known as the “Modulus 10 Algorithm”—is a formula that is used to determine whether the identification number provided by a user is accurate. The formula is widely used in validating credit card numbers, as well as other number sequences such as government Social Security Numbers (SSNs).
Today, the Luhn Algorithm is an essential component in the electronics payments system, and is used by all major credit cards.
- The Luhn Algorithm is a mathematical formula developed in the late 1950s.
- It is widely used to validate the authenticity of identification numbers.
- In finance, it has helped increase electronic payments processing by rapidly identifying mis-entered credit card numbers.
How the Luhn Algorithm Works
The LUHN formula algorithm was developed by a German Computer Scientist named Hans Peter Luhn in 1954 while working as a researcher at IBM. The exact workings of the algorithm are based on modular arithmetic, a mathematical technique developed by Carl Friedrich Gauss in the early 19th century. Although its detailed workings are rather complex, it is best known for allowing computers to quickly assess whether the credit card numbers provided by customers are accurate.
The way it does so is by applying a series of computations to the credit card number given, adding up the results of those computations, and checking whether the resulting number matches the expected result. If it does, then the credit number is deemed valid. If not, the algorithm will reject the credit card number, indicating that the user made an error when inputting the number.
From a customer’s perspective, we use the Luhn Algorithm all the time, without even realizing it. When placing orders online or using a merchant’s point of sale (POS) terminal, computer systems are able to quickly tell when we have made a mistake inputting our information. This is because the Luhn Algorithm has been incorporated into those systems’ programming. Without it, we would need to wait until the entire purchase order is submitted before realizing whether the transaction was approved. The Luhn Algorithm, in other words, helps us quickly identify user errors and thereby speed up the pace of transactions".
Real World Example of the Luhn Algorithm
One of the central concepts within the Luhn Algorithm is the use of so-called “check digits”. These digits consist of numbers that are inserted into the broader number sequence in order to help verify, or “check”, whether the whole number is authentic.
For credit cards, the check digit consists of a single digit printed at the end of the credit card number. Rather than being specifically chosen by the credit card company, the check digit is instead automatically determined by the Luhn Algorithm, based on the preceding numbers in the sequence. When users enter their credit card numbers to complete transactions, the payment processing software can use the Luhn Algorithm to detect whether the specified number is accurate, based in part on its check digit.
Today, the Luhn Algorithm is integrated into popular programming languages and code libraries, making it relatively easy to include Luhn-based identification number verification in new software applications.