The Luhn check test is a modulus 10 checksum that verifies whether a string of digits, such as a payment card number or an IMEI, is mathematically well-formed. It catches single-digit typos and most swapped adjacent digits, and it runs in a single pass with no lookup tables. Passing the test proves only that the digits are internally consistent, not that an account exists, is open, or can be charged.
How does the Luhn algorithm work?
Start at the rightmost digit, which is the check digit, and move left. Double the value of every second digit, and if a doubled value is greater than 9, subtract 9 from it. Add all the resulting digits together.
If the total is a multiple of 10, the sequence passes. Any other remainder means the number contains at least one error.
What is a worked Luhn check example?
Take the sequence 79927398713. Reading from the right, the check digit 3 stays as is, and alternate digits are doubled.
- Doubled positions: 1 becomes 2, 8 becomes 16 then 7, 3 becomes 6, 2 becomes 4, 9 becomes 18 then 9.
- Unchanged positions: 3, 7, 9, 7, 9, 7.
- Total: 3 + 2 + 7 + 7 + 9 + 6 + 7 + 4 + 9 + 9 + 7 = 70.
Because 70 divides evenly by 10, the sequence is Luhn-valid.
What does a passing Luhn check not prove?
A pass says nothing about whether the underlying account is funded, active, or authorized for a purchase. Authorization depends on an issuer response over a payment network, plus fraud screens such as CVV matching, address verification, and 3-D Secure.
A checksum is a data quality filter, not evidence of authenticity. Randomly generated digits hit a valid Luhn checksum about one time in ten.
Which numbers use the Luhn formula?
- Payment card numbers structured under ISO/IEC 7812
- IMEI numbers on mobile devices
- US National Provider Identifiers
- Canadian Social Insurance Numbers
- Some gift card, loyalty, and account numbers
How do you run a Luhn check test?
The three common approaches are hand calculation, a spreadsheet formula, and a short function in any programming language. All three apply the same rule: double alternate digits from the right, reduce values above 9, sum, and test divisibility by 10.
A spreadsheet can do it with a helper row that reverses the digits, applies the doubling rule, and compares the total modulo 10 against zero. Test the formula against a known string such as 79927398713 before trusting it on your own data.
Why do valid numbers fail the Luhn check?
Failures usually come from transcription: a mistyped digit, a transposed pair, or an optical character recognition misread. Because the algorithm is designed to catch exactly those errors, a failure is a strong signal that the input was copied incorrectly.
Is Luhn validation the same as card verification?
No. A Luhn check is a format test you can run locally with no network access. Card verification requires the issuer, and it evaluates account status, available funds, and fraud risk.
Use the Luhn test on your own numbers, on test data, or in authorized development environments. Treating a passing checksum as proof of a live account leads to bad decisions.