Introduction
A book's 13-digit ISBN ends in a digit whose only job is to catch mistakes. Seeing that digit at work shows modular arithmetic doing something practical, and it shows exactly where the method's limits lie. This walkthrough computes the check digit for a real ISBN, then tests it against two kinds of typing error and finds the one kind of slip it misses.
The Starting Point
An ISBN (International Standard Book Number) is a 13-digit number that identifies a book edition. The last digit is a check digit, computed from the first 12 so that copying errors can be detected. The rule uses a weighted sum: multiply the first 12 digits alternately by 1 and 3, then add. The check digit is whatever brings the total up to a multiple of 10 (International ISBN Agency 2017, sec. A1.1). Citations to the ISBN manual give section numbers.
Modular arithmetic is arithmetic that keeps only remainders on division by a fixed number, called the modulus. Here the modulus is 10. A valid ISBN is one whose full weighted sum, including the check digit with weight 1, leaves remainder 0 on division by 10.
The material for this walkthrough is the ISBN the manual itself uses as its example, 978-92-95055-12-4, and two mistyped versions of it:
- The correct ISBN: 978-92-95055-12-4
- A one-digit typo, with the 2 near the end typed as 7: 978-92-95055-17-4
- Two neighbors swapped, with 92 typed as 29: 978-29-95055-12-4
The hyphens only separate parts of the number. They play no role in the calculation.
Walking Through the Check-Digit Calculation
Step 1: Compute the weighted sum of the first 12 digits
Write out the first 12 digits of the correct ISBN and the weights beneath them.
| Digit | 9 | 7 | 8 | 9 | 2 | 9 | 5 | 0 | 5 | 5 | 1 | 2 |
|---|
| Weight | 1 | 3 | 1 | 3 | 1 | 3 | 1 | 3 | 1 | 3 | 1 | 3 |
| Product | 9 | 21 | 8 | 27 | 2 | 27 | 5 | 0 | 5 | 15 | 1 | 6 |
Add the products: 9 + 21 + 8 + 27 + 2 + 27 + 5 + 0 + 5 + 15 + 1 + 6 = 126. That matches the manual's figure (sec. A1.1).
Step 2: Find the check digit
Divide 126 by 10. It goes in 12 times with remainder 6. The check digit is 10 - 6 = 4, the amount needed to reach 130, the next multiple of 10. That matches the 4 printed at the end of the ISBN.
To confirm the whole number, add the check digit with weight 1: 126 + 4 = 130. On division by 10, the remainder is 0. The ISBN passes. If the remainder in this step had been 0, the check digit would be 0, not 10.
Step 3: Change one digit and watch the check fail
Now take the typo version, 978-92-95055-17-4. Only the 12th digit has changed, from 2 to 7. That digit carries weight 3, so its product goes from 6 to 21, an increase of 15.
The weighted sum of the first 12 digits becomes 126 + 15 = 141. Adding the check digit 4 gives 145. On division by 10 the remainder is 5, not 0. The ISBN fails, and the error is caught.
That isn't luck. Changing one digit by an amount between 1 and 9 changes the total by that amount, or by three times that amount. Neither can be a multiple of 10. The numbers 1 to 9 aren't, and three times them gives 3, 6, 9, and so on up to 27, none of which is a multiple of 10 either. So every single-digit typo is caught.
Step 4: Swap two neighboring digits
Now take the swapped version, 978-29-95055-12-4. The 4th and 5th digits have traded places. The 4th position carries weight 3 and the 5th weight 1.
Before the swap, those positions contributed 9 \times 3 + 2 \times 1 = 29. After the swap, they contribute 2 \times 3 + 9 \times 1 = 15. The total drops by 14, from 126 to 112. With the check digit, the full sum is 112 + 4 = 116. The remainder on division by 10 is 6, so the error is caught.
Look at the size of the change: 14 is 2 \times 7, and 7 is the difference between the two swapped digits, 9 and 2. That holds in general. If neighbors a and b swap places, one moves from weight 3 to weight 1 and the other from weight 1 to weight 3. The total changes by 2 \times (a - b), up or down depending on which digit was in the weight-3 position.
Step 5: Find the one kind of swap that slips through
A swap goes undetected only if the change in the total, 2 \times (a - b), is a multiple of 10. For digits between 0 and 9, that happens only when a - b is 5 or −5, that is, when the two neighbors differ by exactly 5. (If they're equal, the swap changes nothing, so there's no error to catch.)
This ISBN has such a pair: the 8th and 9th digits are 0 and 5. Swap them and you get 978-92-95505-12-4. The 8th position carries weight 3, so its product goes from 0 to 15. The 9th carries weight 1, so its product goes from 5 to 0. The total rises by 10, from 126 to 136, and with the check digit it reaches 140. The remainder is 0. The mistyped number passes the check.
Key Considerations
The scheme works modulo 10, and that's why neighbors differing by 5 escape. A swap changes the total by twice the difference between the digits, and twice 5 is 10, which modular arithmetic modulo 10 can't see. Every other kind of single typo or neighbor swap changes the total by an amount that isn't a multiple of 10.
The common mistake is to treat the check digit as a security feature. It isn't one. The rule is published in the manual, and anyone can compute a valid check digit for any 12 digits. A number that passes the check is well formed. It isn't thereby genuine, and it may belong to no book at all. Check digits protect against accidents, not against anyone deliberately inventing a number.
A failed check also doesn't say which digit is wrong. The typo in Step 3 and the swap in Step 4 both fail, but nothing in the remainder points to the 12th digit or the 4th. To fix the number, you go back to the source.
Summary
The check digit makes the full weighted sum a multiple of 10. That catches every single-digit typo and every swap of neighboring digits, except a swap of two digits that differ by 5.
| Version | Weighted sum with check digit | Remainder on division by 10 | Verdict |
|---|
| 978-92-95055-12-4 (correct) | 130 | 0 | Passes |
| 978-92-95055-17-4 (one-digit typo) | 145 | 5 | Fails; error caught |
| 978-29-95055-12-4 (neighbors 9 and 2 swapped) | 116 | 6 | Fails; error caught |
| 978-92-95505-12-4 (neighbors 0 and 5 swapped) | 140 | 0 | Passes; error missed |
- The first row reproduces the manual's own example: the first 12 digits give 126, and the check digit 4 brings the total to 130.
- The typo raised one weight-3 product by 15, which left remainder 5.
- Each swap changed the total by twice the difference of the swapped digits: −14 for 9 and 2, +10 for 0 and 5.
- Only a change that is a multiple of 10 goes unnoticed, which is why the last row slips through.
References
- International ISBN Agency. 2017. ISBN Users' Manual. International ed., 7th ed. London: International ISBN Agency.