Math calculator

Luhn Algorithm Calculator

The check digit, and exactly what it catches.

The check digit, and what it catches

Including a transposition test on your own number.

total 70

passes

The digits total 70. Luhn passes exactly when that is a multiple of ten.

Verdict

valid

the total is a multiple of ten

Full number

79927398713

with the check digit in place

Weighted total

70

after doubling every second digit

Catches a swap here?

yes

transpositions are what Luhn is for

Every second digit from the right, doubled

7 (9→9) 9 (2→4) 7 (3→6) 9 (8→7) 7 (1→2) 3

  • The digits sum to 70. Luhn passes exactly when that total is a multiple of ten, so this passes.
  • Every second digit from the right is doubled, and a result above 9 has 9 subtracted — which is the same as adding its two digits. That doubling is what makes the position of a digit matter, and it is why Luhn catches transpositions.
  • That is precisely the error casting out nines cannot catch: a digit sum is unchanged by swapping two digits, so a check based on it passes every transposition. Weighting by position is the fix, and it is why every modern check digit scheme uses one.
  • Luhn catches every single-digit error and almost every transposition. It is a typo detector, not a security measure — anyone can compute a valid number, and a valid Luhn says nothing about whether an account exists.

This is exactly the error casting out nines cannot catch, because a digit sum is unchanged by swapping two digits.

What this tool shows

Luhn doubles every second digit from the right, and that weighting by position is what lets it catch a transposition — precisely the error a digit sum cannot see, because swapping two digits leaves a sum untouched.

  • Validating a number against its check digit
  • Generating the check digit for a payload
  • The doubling step, shown digit by digit
  • Which errors Luhn catches
  • The one transposition it misses
  • Why a valid number proves very little
Validate or generate Every step shown And what it misses Where it is used

The page tests a transposition on your own number.

Updated 7 September 2026 · Works in any browser, no installation

Double every second digit from the right, subtract 9 from anything over 9, and add it all up. A valid number totals a multiple of ten. The doubling is what makes position matter, and that is what lets Luhn catch a transposition — the error a plain digit sum cannot see.

At a glance

Formula shown
Double every second digit counting from the right; if a doubled value exceeds 9, subtract 9. Sum all the digits. The number is valid when that total is divisible by ten.
Scenario support
Validating a card number in a form before submitting it; generating a check digit for an identifier; understanding why a typo was rejected.
Educational estimate
Planning support from the values you enter — not professional advice.

How the doubling works

Three steps, and the second is the one doing the real work.

Count from the right. The check digit is the last one, and the doubling starts with the digit next to it. Counting from the left instead is the commonest implementation bug, because it gives the right answer only for even-length numbers.

Double every second digit. If the result exceeds 9, subtract 9 — which is the same as adding its two digits, since 16 becomes 7 either way.

Add everything. Doubled values and untouched ones alike. A multiple of ten means the number passes.

The doubling is the whole point. It makes a digit’s contribution depend on where it sits, so moving a digit changes the total — which a plain sum would not notice.

What it catches

Luhn is a typo detector, and it is a good one for its size.

Every single-digit error. Mistype any one digit and the check fails, without exception. This page asserts that on two hundred generated corruptions.

Almost every transposition. Swap two adjacent digits and it is caught — with one exception, below.

That second property is the interesting one, because it is exactly what casting out nines cannot do. A digit sum is unchanged when two digits swap, so any check built on one passes every transposition. Weighting by position is the fix, and it is why every modern check digit scheme uses one.

Transpositions matter because they are among the commonest errors people make when copying numbers — more common than single-digit substitutions in some studies. A scheme that misses them all is missing the wrong half.

What it misses

One transposition escapes: 09 and 90.

Swapping those two digits leaves the Luhn total unchanged, so the check passes on a number that is wrong. It is a known and accepted limitation rather than a bug, and the tool above will show it to you if you enter a number containing that pair.

It also misses most two-digit errors that happen to compensate for each other, and it catches about 90% of twin errors like 22 becoming 55.

Better schemes exist. The Verhoeff algorithm catches all single-digit errors and all transpositions including 09/90, using a dihedral group rather than simple doubling. It is strictly better and almost nobody uses it, because Luhn was standardised first and is easier to compute by hand.

Where it is used

Luhn is in more places than most people realise.

Payment cards. Every card number ends in a Luhn check digit, which is why a mistyped number is rejected instantly rather than after a network round trip.

IMEI numbers. Every mobile phone’s identifier carries one.

National identifiers. Canadian Social Insurance Numbers, South African ID numbers, and several others.

Test numbers. The card numbers used in payment sandboxes are Luhn-valid and belong to no account, which is exactly why they work for testing form validation.

Hans Peter Luhn patented it at IBM in 1960. The patent expired long ago, which is part of why it spread so widely.

What it does not prove

Worth being explicit, because this gets misunderstood in both directions.

A valid Luhn check means the number is well-formed. It does not mean an account exists, that it has funds, that it belongs to anyone, or that it is not stolen.

It offers no security whatsoever. The algorithm is public and takes a moment to compute, so generating valid-looking numbers is trivial. It stops typos, not fraud.

Its actual value is in the user experience and in bandwidth: catching a mistyped digit in the browser, before a request is sent, is faster and less frustrating than catching it at the payment processor.

Treating a Luhn check as validation of anything more than formatting is a genuine mistake, and one that appears in real systems.

Sources and methodology

Luhn is a published standard; these are the references.

Method. Both directions are computed by the same routine, so generating a check digit and then validating the result cannot disagree — the suite generates five hundred check digits and requires every resulting number to validate. The transposition test is run on the reader’s own number rather than described: the first adjacent unequal pair is swapped and re-checked, which also surfaces the 09/90 pair Luhn cannot catch. Every single-digit corruption is asserted to be caught across two hundred generated cases. That engine is verified on every change against 90 hand-written assertions, including that every generated check digit produces a number that validates, and that every single-digit error is caught across two hundred generated corruptions. The count and the per-case breakdown are published on the formula verification page.

Related calculators

Where this goes next:

Digital RootEvery round of digit addition shown, with the mod-9 shortcut alongside — and a casting-out-nines checker that will show you a wrong sum passing.
ModuloAll three conventions at once, because −7 mod 3 is −1 in JavaScript and 2 in Python and a page that gives only one of those is wrong for half its readers.
Binary ArithmeticAdd, subtract, multiply and divide in binary, octal or hex — with the carry row shown, and what a processor actually does instead of subtracting.
Place ValueEvery digit named and valued, in all three expanded forms and in words — including the decimals, where the first place after the point is tenths and not 'oneths'.
Twos ComplementTwo's and one's complement at 8 to 64 bits, with the signed range and its asymmetry — and why negating the minimum gives back the minimum.
Prime NumberWhether a number is prime, with a divisor named when it is not and the size of the search stated when it is. Deterministic, not probabilistic.

More in Math, or browse all calculators.

Read the guide

Casting out nines is the check that cannot catch a transposition — the Digital Root Calculator shows why, and lets you watch a wrong sum pass.

Educational use disclaimer

This is an educational tool. A valid Luhn check means a number is well-formed, not that any account exists — it is a typo detector, not a security measure.

How we calculate · Found an error? email us

Authorship & verification

Written and maintained by , a business operator who builds spreadsheet-based calculators.

What's changed (3 updates)

Published 7 September 2026

  1. Published the Luhn page testing a transposition on the reader's own number rather than asserting that it catches them — swapping the first adjacent unequal pair and re-checking, which also surfaces the 09/90 pair Luhn cannot catch.
  2. Connects directly to the Digital Root page: casting out nines misses every transposition because a digit sum is unchanged by swapping two digits, and Luhn's doubling by position is exactly the fix.
  3. States plainly what a valid Luhn does NOT prove — it means well-formed, not that an account exists — since treating it as validation of anything more appears in real systems.

Add this calculator to your site

Responsive embed — and private: nothing your visitors type leaves their browser.