
The Luhn algorithm was developed by Hans Peter Luhn and IBM in 1954. It is also known as the Luhn Check or Mod Check.
The Luhn algorithm is used in two ways.
- Preparing a given number according to the Luhn algorithm (with the check digit value)
- Validating a given number according to the Luhn algorithm
Check Digit Calculation
The check digit value is a value calculated based on mod 10 of the sum of the values other than the check digit itself. The algorithm works as follows:
- The rightmost digit is the check digit. Starting from the check digit, we multiply the 1st, 3rd, 5th... digits by 2. (The 2nd, 4th, 6th... digits remain unchanged.)
- If the sum of the values is greater than 9, we add their digits together to find the sum of the digits.
- Finally, all the resulting digits are added together.
- The sum of the digits is multiplied by 9.
- The last digit of the resulting number is the check digit value.
Example
Card Number
| Card no | 3 | 7 | 1 | 4 | 4 | 9 | 6 | 3 | 5 | 3 | 9 | 8 | 4 | 3 | X |
Step 1 - Multiply the values by 2
| Multiply by 2 | 3 | 14 | 1 | 8 | 4 | 18 | 6 | 6 | 5 | 6 | 9 | 16 | 4 | 6 | X |
Step 2 - Add the resulting values
| Add the Values | 3 | 5 | 1 | 8 | 4 | 9 | 6 | 6 | 5 | 6 | 9 | 7 | 4 | 6 | X |
Step 3 - Add all the values
3 + 5 + 1 + 8 + 4 + 9 + 6 + 6 + 5 + 6 + 9 + 7 + 4 + 6 = 79
Step 4 - Multiply by 9
79 x 9 = 711
Result
Check Digit Value = 1.
You can use the tool at the link below to calculate the check digit value.
http://www.datageneratortools.com/card/calculator
Check Digit Validation
You can see how a given number is validated according to the Luhn algorithm in the image below.

- Starting from the rightmost check digit and moving left, we multiply the 1st, 3rd, 5th... digits by 2.
- If the sum of the values is greater than 9, we add their digits together to find the sum of the digits.
- Finally, all the resulting digits are added together.
- If the total sum is a multiple of 10, the card number is valid. If it is not a multiple of 10, the number is invalid.
Example
Card number
| Card No | 3 | 7 | 1 | 4 | 4 | 9 | 6 | 3 | 5 | 3 | 9 | 8 | 4 | 3 | 1 |
Step 1 - Multiply the values by 2
| Multiply the Values | 3 | 14 | 1 | 8 | 4 | 18 | 6 | 6 | 5 | 6 | 9 | 16 | 4 | 6 | 1 |
Step 2 - Add the Values
| Add the Values | 3 | 5 | 1 | 8 | 4 | 9 | 6 | 6 | 5 | 6 | 9 | 7 | 4 | 6 | 1 |
Step 3 - Add All the Values
3 + 5 + 1 + 8 + 4 + 9 + 6 + 6 + 5 + 6 + 9 + 7 + 4 + 6 + 1= 80
Step 4 - According to Mod 10 (80/10=8, divides evenly.)
80 % 10 = 0
Result:
The card number is Valid.
If you want to validate a card number, you can use the link below.



