Sycurio Glossary.

Luhn / Luhn-check

The Luhn algorithm, also known as the Luhn formula or Luhn check, is a mathematical formula used to validate the integrity and authenticity of various identification numbers, including payment card numbers. It is commonly used to check the accuracy of credit card numbers, debit card numbers, and other numeric identifiers.

The Luhn algorithm works by performing a simple calculation on the digits of the identification number and comparing the result with a predetermined check digit. Here's how it works:

Starting from the rightmost digit, double the value of every second digit. If the doubled value results in a two-digit number, sum the digits of that number together. For example, if a digit is 5, its doubled value would be 10, and the sum of the digits would be 1+0=1.

Add up all the resulting digits, including the unchanged digits from the original number.

If the total sum is divisible by 10 (without any remainder), the identification number is considered valid according to the Luhn algorithm.

The purpose of the Luhn algorithm is to detect common errors in input or transcription of identification numbers, such as mistyping a digit or transposing digits. By performing the calculation and verifying the check digit, it helps identify potentially invalid or fraudulent card numbers.

For example, consider the credit card number 4 5 1 2 3 4 5 6 7 8 9 0 1 2 3 4. Applying the Luhn algorithm:

Double every second digit, starting from the right: 4 10 1 4 1 6 1 10 2 8 1 0 2 6 3 4.

Sum all the resulting digits: 4 + 1 + 1 + 4 + 1 + 6 + 1 + 1 + 0 + 2 + 8 + 1 + 0 + 2 + 6 + 3 + 4 = 55.

Since 55 is divisible by 10 without any remainder, the credit card number passes the Luhn check and is considered valid.

The Luhn algorithm provides a quick and easy way to perform a basic validation check on identification numbers, including payment card numbers. It is commonly used in payment processing systems to help ensure the accuracy and integrity of entered card numbers before proceeding with transaction processing.

Back to Glossary