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.
- Leave the rightmost digit (position 1) as it is.
- Double every digit in positions 2, 4, 6, … from the right.
- Whenever doubling gives a two-digit number, add its digits (equivalently: subtract 9).
- Add everything. The number is valid if the total is a multiple of 10.
In congruence language: if is that weighted sum, validity means .
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 right | Digit | Doubled? | Contribution |
|---|---|---|---|
| 1 | 7 | no | 7 |
| 2 | 5 | yes | 1 |
| 3 | 2 | no | 2 |
| 4 | 1 | yes | 2 |
| 5 | 4 | no | 4 |
| 6 | 8 | yes | 7 |
| 7 | 2 | no | 2 |
| 8 | 1 | yes | 2 |
| 9 | 0 | no | 0 |
| 10 | 5 | yes | 1 |
| 11 | 1 | no | 1 |
| 12 | 0 | yes | 0 |
| 13 | 2 | no | 2 |
| 14 | 3 | yes | 6 |
| 15 | 5 | no | 5 |
| 16 | 4 | yes | 8 |
Total: . And .
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 . Run Luhn. Solve for 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 directly.
We need:
So .
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.
| Stage | What you are really doing |
|---|---|
| This seminar | Modular arithmetic mod 10, weighted sums |
| Olympiad level | Congruences, systematic casework, proving a procedure catches certain error types |
| University | Error-detecting codes, Hamming distance, ISBN and IBAN checks |
| Deeper | Coding theory over finite fields; Reed–Solomon codes in QR codes, CDs, and storage |
| Information theory | How 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 ?
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.
