The Luhn (mod 10) algorithm, patented by IBM’s Hans Peter Luhn in 1960, catches almost all single-digit typing errors and most swaps of adjacent digits. It protects credit card numbers, IMEI codes and many ID numbers.
How to use the Luhn Algorithm Calculator
- Mode
- Number
Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.
How it works
Choose whether you want a check digit or a validation, then enter the digits (spaces are ignored). This is purely a typo check – it says nothing about whether a card exists.
Formula
From the right, double every second digit (subtract 9 if > 9) and add all digits; valid if the total is divisible by 10
Worked example
Inputs — Mode: Generate a check digit; Number: 7992739871.
Results — Result = Check digit: 3; Checksum = Sum with every second digit doubled (from the right) = 67, so the check digit is (10 − 7) mod 10 = 3; Full number with check digit = 79927398713.
Key terms
- Check digit
- A digit added to detect errors.
Frequently asked questions
Does a valid Luhn number mean a real card?
No – it only checks for typing mistakes.
Which errors does Luhn miss?
Swapping 09 and 90, and some twin errors like 22 ↔ 55.
Where is it used?
Credit cards, IMEI numbers, Canadian SIN and many loyalty cards.
Is the algorithm secret?
No, it is public and in the public domain.