How the Luhn algorithm works
The check runs over the whole number, check digit included. For 4111 1111 1111 1111 the total is 30, so the number passes.
- Start at the rightmost digit and move left
- Double every second digit, beginning with the one next to the rightmost
- Where doubling gives a two-digit result, subtract 9
- Add up all the digits
- The number is valid if the total is divisible by 10
Where the Luhn algorithm comes from
Hans Peter Luhn of IBM filed a patent for a device that computes such a check digit on 6 January 1954, and the patent was granted on 23 August 1960 as US 2,950,048. The formula is public and is used well beyond cards.
The card schemes rely on it. The Mastercard Rules of 2 June 2026 define a token as a value that passes the basic validation rules for a card number, including the Luhn formula for computing a modulus 10 check digit.
What the Luhn check does in a payments product
A payment form runs the check as the customer types, to catch a slip before an authorisation is attempted. Published test card numbers pass the check as well, which is why a form accepts them.
The check says nothing about whether a card exists, has funds or belongs to the person typing. Fraudsters generate valid numbers under a known BIN in bulk, which is the basis of a BIN attack, so the check is a convenience for honest customers and no part of fraud control.
Where the Luhn algorithm shows up in a platform
Modules that do the work
- CheckoutA hosted checkout for cards, wallets, bank payments and crypto, routed to the best provider.
- Card acquiringCard acceptance on the phone, in store and online, through the acquirer you choose.
- Fraud & riskReal-time fraud scoring, limits and case management, with the risk engines you already trust.
Platforms that need it
Where it is written
The laws and standards this page's facts come from.
- US Patent 2,950,048, Computer for Verifying Numbers, H. P. Luhn, granted 23 August 1960 (Google Patents)
- Mastercard Rules, 2 June 2026: definitions, Token (Mastercard)
General information, not legal advice: what applies to you depends on your services and your market.