StatGardenREF. DESK
Calculators/Maths/Luhn algorithm (checksum)
Maths

Luhn algorithm (checksum) calculator

Validates a number sequence or computes the check digit that makes it valid.

Published 8 August 2026 · Updated 24 September 2026

What this calculator does

The Luhn algorithm is the checksum behind credit card numbers, and it is designed to catch the errors people actually make: a mistyped digit, or two adjacent digits swapped.

The doubling step is what catches transpositions. Every second digit from the right is doubled, with 9 subtracted if the result exceeds 9, and a valid number has a digit total divisible by 10.

The formula

FormulaFrom the rightmost digit, double every second digit (subtract 9 if over 9); valid when the total digit sum is divisible by 10

Working from the rightmost digit, every second digit is doubled and reduced by 9 if it exceeds 9. All digits are summed, and a total divisible by 10 indicates validity.

TermMeaning
ChecksumA digit computed from the others to detect errors.
Check digitThe final digit, chosen to make the total come out right.
Transposition errorSwapping two adjacent digits, which the algorithm catches in most cases.

The inputs explained

FieldWhat to enter
Digits (spaces allowed)The digits to check or extend. Spaces and other non-digit characters are ignored.
ModeWhether to validate the sequence as given, or compute a check digit to append.

When to use it

Validating a card number

A failed Luhn check catches a typo before any network request is made.

Generating test data

Valid-looking test numbers need a correct check digit.

Understanding how checksums work

Luhn is the most widely encountered example.

Worked examples

Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.

What happens when one digit changes?

The same number with its last digit altered.

Validating a sixteen digit sequence
SequenceValid by the Luhn check?Digit sum (mod 10)
4539 1488 0343 6467Yes0
4539 1488 0343 6468No1
The first sequence passes with a digit sum ending in 0. Changing only the final digit from 7 to 8 breaks it, giving a remainder of 1 and failing the check.

Questions

What errors does Luhn catch?

All single-digit errors, and most transpositions of adjacent digits. The notable exception is swapping 09 for 90, which the doubling step happens not to detect.

Is Luhn a security measure?

Not at all. It is an error-detection check, and the algorithm is completely public. Generating a number that passes is trivial, which is why passing the check proves only that the digits were typed correctly.

Where else is it used?

Beyond payment cards, it appears in IMEI numbers for mobile phones, some national identification numbers, and various product codes. Any context wanting a cheap typo check is a candidate.

Why double every second digit?

Because it makes the checksum position-sensitive. Without doubling, swapping two digits would leave the sum unchanged and the error would pass undetected, which is precisely the failure the algorithm exists to prevent.

For modular arithmetic generally, see the modular exponentiation calculator. For digit-based checks, see the digital root calculator.