LearndleNo. 3Monday 30 November 2026

The digit that checks the others

How does a barcode scanner know it has misread a code?

About 8 minutesTechnology

1 The question

The last digit says nothing about the product

6291041500213
The example number from GS1, the body that hands out barcode numbers. The boxed digit is the check digit.

A barcode on a pack in a European shop carries 13 digits. The first twelve identify the product: a number for the company and a number for the item. The thirteenth says nothing about the product at all.

It is worked out from the other twelve, and it has one job. A scanner reads the bars through creases, smudges and glare. When it gets a digit wrong, the last digit should give it away, so the till does not ring up the wrong thing.

In about 8 minutes you will be able to

  • Explain how one check digit catches every single wrong digit in a barcode.
  • Say which swapped digits a barcode check cannot catch, and why.
  • Judge whether another check digit rule is stronger or weaker.

2 Your guess

How good is one digit?

One extra digit can only take ten values, 0 to 9. A wrong reading has a lot of ways to go wrong.

The scanner misreads exactly one of the 13 digits. How often does the check digit catch the mistake?

  1. About 1 time in 10.
  2. About 9 times in 10: now and then a wrong digit happens to fit.
  3. Every time.

Pick one in your head before you read on.

Pick an answer to go on.

3 Try it

Try to fool the scanner

Below is what the scanner read. Type over any digit, or use the arrow keys on it, to make it misread. The scanner multiplies the digits by 1 and 3 in turn, adds them up, and accepts the reading only if the total ends in 0.

What the scanner read. On the pack: 6 291041 500213
6291041500213
6
2
9
1
0
4
1
5
0
0
2
1
3

Total 60, it ends in 0.

Accepted. This is the code on the pack.

Which mistake slipped past the scanner?

  1. Any swap: the scanner never notices swaps.
  2. A swap of two digits that are 5 apart, such as 5 and 0.
  3. A swap in the middle of the code.
Show the answer

A swap of two digits that are 5 apart, such as 5 and 0.

A swap of two digits that are 5 apart leaves the last digit of the total as it was. In this code, swapping digits 8 and 9 (a 5 and a 0) gets through. The next step shows why only those pairs.

Try these

  • Change one digit of the reading.not done yet
  • Swap two neighbouring digits that are not the same.not done yet
  • Find a mistake the scanner does not notice.not done yet

Do the three things in the list, then answer the question, to go on.

4 Why

Times 3 never lands on a ten

A wrong digit changes the total. The scanner only looks at the last digit of the total. So a mistake can only hide if it changes the total by a whole number of tens: by 10, 20, 30 and so on.

One wrong digit

A digit can be wrong by 1 to 9. At a place with weight 1, the total changes by the same amount, never a whole ten. At a place with weight 3, it changes by three times as much. Look at the last digit of each:

How much the last digit of the total moves when one digit is wrong
Digit wrong by123456789
Times 3369121518212427
If it were times 224681012141618

Times 3 never gives a whole ten, so every single wrong digit shows. That is why the weight is 3. A weight of 2 would fail: a digit wrong by 5 would change the total by exactly 10, and slip through. The weight must share no factor with 10.

Two neighbours swapped

Neighbours always have one weight of 1 and one of 3. Swap a digit a and a digit b, and the total changes by twice the gap between them. That is a whole ten only when the gap is 5.

second digit first digit 00112233445566778899
Every swap of two different neighbours. Green: caught. Red: slips through. Grey: the digits are the same, so nothing changes. 80 of the 90 swaps are caught, so about 1 swap in 9 gets through.

If you guessed 1 time in 10

You guessed 1 time in 10. That would be true if the check digit were random. It is not: it is chosen so that the total ends in 0, and every single wrong digit moves that total off the ten. It catches all of them.

If you guessed 9 times in 10

You guessed 9 times in 10. A close guess, and true for a random kind of mistake: two wrong digits get through about 1 time in 9. But one wrong digit never fits, because times 1 and times 3 never make a whole ten. It catches all of them.

If you guessed every time

You guessed every time. That is right, for one wrong digit. You have also seen where the check stops: some swaps, and some pairs of mistakes.

5 Use it

Three new situations

Use what you found out. A wrong answer explains itself, and you can try again. Only your first try counts for your result.

A cashier types a barcode number by hand and gets two digits wrong. Is the mistake always caught?

  1. Yes: the check digit catches every wrong digit.
  2. No: two mistakes can cancel each other out.
  3. No: two mistakes are never caught.
Show the answer

No: two mistakes can cancel each other out.

Each mistake moves the total. If the second one moves it back to a whole ten, the reading passes. For two random mistakes that happens about 1 time in 9.

Someone suggests weights of 1 and 2 instead of 1 and 3. What would change?

  1. It would be better in every way.
  2. It would catch every swap, but miss some single wrong digits.
  3. Nothing: any weights work.
Show the answer

It would catch every swap, but miss some single wrong digits.

A digit wrong by 5 at a times 2 place changes the total by exactly 10, so it slips through. In exchange, every swap would be caught: it would change the total by the gap between the digits, never a whole ten. Barcodes chose to catch every single wrong digit.

Old 10 digit book numbers (ISBN-10) use weights 10, 9, 8 and so on down to 1, and count in elevens instead of tens. They catch every single wrong digit and every swap of neighbours. Why can elevens do what tens cannot?

  1. Because 11 shares no factor with any of the weights or gaps, so no mistake adds up to a whole eleven.
  2. Because book numbers are shorter than barcode numbers.
  3. Because 11 is bigger than 10, so there is more room.
Show the answer

Because 11 shares no factor with any of the weights or gaps, so no mistake adds up to a whole eleven.

11 is a prime number. A mistake changes the total by a weight (1 to 10) times a gap (1 to 9), and no such product is a whole number of elevens. The price: the check digit can come out as 10, which is printed as an X.

Find the right answer to all three questions to finish.

6 Done

What you found out

The check digit is picked so that a weighted total ends in 0. Times 1 and times 3 never turn a single wrong digit into a whole ten, so every single misread shows. A swap of two neighbours that are 5 apart is the one simple mistake it misses.

The same idea is used in book numbers and in the check digits of many other codes. Each one picks its rule so that the most common mistakes cannot add up to a whole multiple.

Your result

    The text says how you did, not what the answer is.

    A day counts for the streak when you finish that day’s discovery on that day, by your own clock. Finishing an older one from the archive marks it done, but it does not add to the streak.

    Sources, and what the models leave out

    The pages below could not be opened directly while this edition was made, so each fact was checked through search results that quote them, in at least two places. The 80 of 90 swaps and the 1 in 9 for two mistakes are worked out here, not quoted. The number used on this page is the example from GS1’s own guide, not a product. Real scanners have more checks than the check digit: the bar patterns themselves follow strict rules, so many misreads are caught before the sum is ever done. This edition looks only at the check digit.