Mathematics7 min read

Decoding the Missing Digit


Published on

15 May 2026

Contributors

George Ionitsa
George Ionitsa

Quant Developer and Olympiad Coach

Decoding the Missing Digit

At Westminster Under we decoded a card number on the whiteboard — then solved for the missing digit using the Luhn check. Synthetic example only; the lesson was about mod-10 structure, not memorising rules.

At a Westminster Under School seminar in May, I asked a question that sounds mundane until you stop to think about it.

"What is the last digit on your card actually for?"

Someone said fraud prevention. Fair enough.

Someone else said the bank assigns it. Also fair.

Nobody said modular arithmetic.

That was the opening I wanted.

I wrote a real number on the board

I took my own card, read the sixteen digits aloud, and wrote them on the whiteboard.

The room went still in the way rooms go still when something ordinary suddenly looks like it might have structure.

We were not going to memorise a rule from a slide. We were going to decode the number — digit by digit — and see whether the last one was arbitrary or forced.

(I am not reproducing my real card number here. Everything below is a synthetic example with the same structure. Please do not paste real card details into articles, homework, or group chats.)

Our practice number:

4532 0150 1284 1257

Sixteen digits. The last digit is the check digit. The first fifteen are the payload. The algorithm that links them is called the Luhn algorithm, after Hans Peter Luhn, an IBM researcher. It is the standard check used on most credit and debit card numbers, and on many other identifiers besides.

Why this is not trivia

When a human types a long number, errors happen.

A wrong key. A transposed pair of digits. A digit doubled by accident.

Payment systems cannot run an expensive authorisation on every typo. They need a cheap filter first: does this string even look structurally plausible?

That is what a check digit is for. Not secrecy. Not encryption. Error detection — catching common mistakes before deeper checks run.

I first met this mindset in quant and data work: pipelines that ingest millions of records, where a single bad identifier can poison a join. You validate early, with simple arithmetic, before you trust the row.

Same idea on a card terminal. Same family of thinking on a National Insurance number or a US Social Security number — though those use different validation recipes, not Luhn itself. More on that later.

The Luhn algorithm

Read the digits from right to left. Number the positions starting at 1 on the right.

  1. Leave the rightmost digit (position 1) as it is.
  2. Double every digit in positions 2, 4, 6, … from the right.
  3. Whenever doubling gives a two-digit number, add its digits (equivalently: subtract 9).
  4. Add everything. The number is valid if the total is a multiple of 10.

In congruence language: if SS is that weighted sum, validity means S0(mod10)S \equiv 0 \pmod{10}.

Luhn algorithm steps on a card number

It looks arbitrary until you do it once. Then it looks tight.

We decoded it together

We took 4532 0150 1284 1257 and worked from the right.

Position from rightDigitDoubled?Contribution
17no7
25yes1
32no2
41yes2
54no4
68yes7
72no2
81yes2
90no0
105yes1
111no1
120yes0
132no2
143yes6
155no5
164yes8

Total: S=50S = 50. And 500(mod10)50 \equiv 0 \pmod{10}.

Students called out the doubled values. I wrote the running partial sums. Two of them were keeping independent tallies to catch arithmetic slips — which is exactly what check digits are for at scale.

When the final sum hit 50, someone said: "So it had to be a multiple of ten."

Yes. That is the whole point. The last digit is not decorative. It is the digit that makes the congruence work.

That was the moment the lesson clicked. Not "remember the rule." The rule is the only digit that can finish the sum correctly.

The missing-digit challenge

Once the algorithm was in the air, I gave them a second number with one digit blanked:

4532 0150 1284 1?25

Same procedure. Treat the missing digit as xx. Run Luhn. Solve for xx modulo 10.

The check digit 5 and every other known digit contribute 49 in total. The missing digit sits in position 3 from the right — it is not doubled — so it contributes xx directly.

We need:

49+x0(mod10)49 + x \equiv 0 \pmod{10}

So x=1x = 1.

Full number: 4532 0150 1284 1125.

The room split into two approaches: trial from 0 to 9 (fast when you are already in mod 10), and algebraic solve. Both are fine. The point was that everyone could verify the answer independently — no authority required.

That exercise is what they remembered. Not the history of IBM. The moment the missing digit snapped into place.

Same family, different recipes

Credit cards use Luhn. So do many IMEI numbers on phones.

But a UK National Insurance number is not Luhn-checked. Neither is a US Social Security number. IBANs use a mod-97 check. ISBN-13 uses a different weighted sum mod 10.

The family is the same: attach a small amount of redundant information so typical human errors surface immediately. The recipe changes with the identifier.

That distinction matters. Students often hear "check digit" and assume one universal formula. In practice it is a design choice — trading off how many errors you catch, how easy the check is by hand, and how long the number needs to be.

In finance and data engineering, you see the same pattern at scale: schema validation, checksum columns, hash prefixes. The whiteboard version is Luhn. The production version is often Reed–Solomon or a cryptographic hash. Same instinct: do not trust the string until the arithmetic says you can.

Where this goes in real mathematics

If the lesson stops at "memorise Luhn," you have learned a party trick. If you follow the thread, you arrive somewhere serious.

StageWhat you are really doing
This seminarModular arithmetic mod 10, weighted sums
Olympiad levelCongruences, systematic casework, proving a procedure catches certain error types
UniversityError-detecting codes, Hamming distance, ISBN and IBAN checks
DeeperCoding theory over finite fields; Reed–Solomon codes in QR codes, CDs, and storage
Information theoryHow much redundancy you need to detect — or correct — random noise

Luhn is a tiny error-detecting code. It catches many single-digit typos and some transpositions. It does not catch every possible mistake. Neither does any single-digit check. That limitation is itself a mathematical question: what is the best you can do with one extra decimal digit?

That is not school maths filler. That is the doorway to how reliable systems are built.

Your turn

Try the missing-digit puzzle on paper before you reach for a calculator:

4532 0150 1284 1?25

What is xx?

Then change one known digit and see whether the check still passes. You will quickly discover which errors Luhn catches and which it misses. That gap is where the next questions live.

If you want seminars like this — depth-first, proof-oriented, built for students who already enjoy the subject — that is what our school partnership programme with Westminster Under is for. For solo practice between sessions, problems.cc has plenty of non-routine material that rewards the same habit: read the structure before you compute.