The Luhn Check: Demystifying Modulo 10 Credit Card Validation
How does a simple Mod 10 equation catch typing errors instantly before hitting bank servers? Learn the step-by-step math of the Luhn algorithm and how card networks identify prefixes.

What is the Luhn Algorithm?
The Luhn Algorithm, also known as the Modulo 10 or Mod 10 algorithm, is a simple checksum formula used to validate a variety of identification numbers. Invented by IBM scientist Hans Peter Luhn in 1954, it is most famous for its application in credit cards, debit cards, SIM card numbers, and social security identifiers.
It is important to understand that the Luhn algorithm is not a cryptographic security method. It is not designed to prevent fraud or determine if a card is active. Instead, it is a validating checksum designed to catch accidental typing mistakes, such as single-digit entry errors or digit transpositions (swapping two adjacent digits like 45 instead of 54).
The Mathematics: How the Checksum works
The Luhn algorithm validates a number sequence by executing four straightforward arithmetic steps:
- Identify and Double: Starting from the rightmost digit (which is the check digit) and moving left, double the value of every second digit.
- Adjust Double Digits: If doubling a digit results in a number greater than 9 (e.g.
8 × 2 = 16), sum the individual digits of that product (1 + 6 = 7). Alternatively, simply subtract 9 from the product (16 - 9 = 7) to get the same result. - Sum all digits: Sum all of the adjusted digits and the original undoubled digits together.
- Modulo 10 Check: If the total sum is congruent to 0 Modulo 10 (meaning the sum ends in a 0), the number sequence is valid.
Step-by-Step Luhn Example
Let's validate the short sequence 49927398716:
| Step details | Value Sequence |
|---|---|
| Original Number | 4 9 9 2 7 3 9 8 7 1 6 |
| Doubling Multipliers | ×1 ×2 ×1 ×2 ×1 ×2 ×1 ×2 ×1 ×2 ×1 |
| Subtotal products | 4 18 9 4 7 6 9 16 7 2 6 |
| Adjusted sums (sub 9) | 4 9 9 4 7 6 9 7 7 2 6 |
Summing these adjusted digits: 4 + 9 + 9 + 4 + 7 + 6 + 9 + 7 + 7 + 2 + 6 = 70.
Applying Modulo 10: 70 % 10 = 0.
Because the remainder is 0, the checksum is Valid.
How Card Brands are Identified (IIN Prefixes)
Before checking the Luhn sum, payment gateways look at the first few digits of the card number, called the Issuer Identification Number (IIN) or Major Industry Identifier (MII), to detect the network brand:
- Visa: Always starts with the digit
4. Lengths: 13, 16, 19. - Mastercard: Starts with prefixes
51–55or2221–2720. Length: 16. - American Express (Amex): Starts with
34or37. Length: 15. - Discover: Starts with
6011,65, or range622126–622925. Lengths: 16–19. - JCB: Starts with
3528–3589. Lengths: 16–19.
Check and Explore Card Numbers Safely
Need to verify card layouts for testing? Use our free Luhn Credit Card Validator. Input any sequence to automatically detect its network brand, check standard lengths, and view a fully interactive visual grid of the doubling and addition steps. Everything runs locally on your machine—no credit card details are ever transmitted over the network.