Advertisement

Luhn algorithm calculator

Generate a Luhn check digit or validate a digit string while preserving leading zeros. See each digit contribution in a step table.

Calculator

Use digits only, with no spaces or punctuation. Validation includes the final check digit.

Check digit
3
Number including check digit
79927398713
Luhn sum
67.00000000
Digit contributions
Position from leftDigitDoubled?Contribution
1.007.00No7.00
2.009.00Yes9.00
3.009.00No9.00
4.002.00Yes4.00
5.007.00No7.00
6.003.00Yes6.00
7.009.00No9.00
8.008.00Yes7.00
9.007.00No7.00
10.001.00Yes2.00

Advertisement

How this calculator works

Starting from the right of a complete number, leave the check digit alone and double every second payload digit. Subtract 9 from any doubled value above 9, then sum the contributions. For generation, parity is offset because the new check digit will be appended. The check is arithmetic only and makes no claim about an account being issued or active.

Formula

Valid complete number: sum(contributions) ≡ 0 mod 10. Appended digit = (10 - payload sum mod 10) mod 10.

Worked example

The payload 7992739871 has a transformed sum of 67. Appending 3 makes the total 70, so 79927398713 passes. The payload 0001 needs digit 8, giving 00018.

Advertisement

Frequently asked questions

Are leading zeros preserved?

Yes. The input is a digit string and the complete result keeps every leading zero.

Does Valid mean an account exists?

No. It only means the number passes this checksum. No account service is contacted.

Which mistakes are detected?

Single-digit substitutions are detected. Some transpositions, including 09 versus 90, can pass unchanged, so this is not a guarantee against all typing errors.

Sources

Advertisement