The number printed under the barcode of every book has thirteen digits, and the last one carries no information at all. Its only job is to catch someone typing the other twelve wrongly.
The rule is fixed and public. Take the twelve digits in order and multiply them alternately by one and by three — first digit by one, second by three, third by one, and so on. Add the twelve results. The check digit is whatever must be added to that total to reach the next multiple of ten.
Suppose the twelve digits give a weighted total of ninety-five. The next multiple of ten is one hundred, so the check digit is five. If the total already ends in zero, the check digit is zero.
The point of the arrangement is that almost any single mistyped digit changes the total, and therefore fails the test. The number is rejected before it ever reaches a catalogue, and nobody spends an afternoon hunting for a book that does not exist.
There is a habit buried in that design worth carrying into any form you fill in. A machine reads exactly what you typed, in the exact format it expects, and it has no way of knowing what you meant. A correct value in the wrong shape is not a small problem. To the machine it is simply wrong.