What is the Luhn Algorithm?
The Luhn algorithm, also called the "mod 10" algorithm, is a simple checksum formula created by IBM scientist Hans Peter Luhn in 1954. It is used to validate identification numbers such as credit and debit card numbers, IMEI phone serial numbers, and many national identification numbers. It detects single-digit errors and most transposition mistakes, but it is not a cryptographic security measure — only a basic data-integrity check.
How to Use This Calculator
Type the number you want to verify into the field (spaces and dashes are ignored automatically). The calculator processes the digits, applies the Luhn checksum, and tells you whether the number is VALID or INVALID, along with the running sum, the sum modulo 10, and the trailing check digit.
The Formula Explained
Read the digits from right to left. Leave the rightmost (check) digit as-is, then double every second digit. If doubling produces a number greater than 9, subtract 9 from it (equivalent to adding the two digits, e.g. \(8\times2=16 \to 1+6=7\)). Add up every resulting value. If the total is divisible by 10, the number passes the Luhn check.
$$\text{Valid} \iff \left(\sum_{i=0}^{n-1} f(d_i)\right) \bmod 10 = 0 \\[1.5em] \text{where}\quad \left\{ \begin{aligned} d_i &= i\text{-th digit of } \text{Number} \text{ (from right)} \\ f(d_i) &= \begin{cases} d_i & i \text{ even} \\ 2d_i - 9\,[2d_i>9] & i \text{ odd} \end{cases} \end{aligned} \right.$$
Worked Example
Take the number 79927398713. Doubling every second digit from the right and reducing values over 9 yields the adjusted digits whose total is 70. Since \(70 \bmod 10 = 0\), the number is valid.
FAQ
Does a valid Luhn result mean a card is real? No. It only confirms the number is well-formed; it does not check whether the account exists or has funds.
What characters are allowed? Only digits are used; spaces, dashes and other symbols are stripped before calculating.
Why subtract 9 when doubling? Subtracting 9 from a doubled digit over 9 gives the same result as summing its two digits, which is exactly what the original Luhn rule requires.