Check Characters on Eight-Character Borrower Codes
A regional library network issues eight-character borrower codes. The first seven characters are digits d1…d7 chosen by the branch; the eighth is a check character c computed by c ≡ d1 + 2d2 + 3d3 + 4d4 + 5d5 + 6d6 + 7d7 (mod 11), where a residue of 10 is printed as the letter X. During a data migration a clerk must hand-verify a batch of records and faces three jobs. A new code must be issued for the prefix 4 0 7 2 1 5 3. One archived record reads 5 2 ? 1 4 0 6 and shows X in the check position, so the third digit has been smudged and must be recovered. Finally, a supervisor wants to know whether the scheme is worth keeping at all, given that the most common keyboard error is swapping two adjacent digits. The clerk is told that every weight 1 to 7 is invertible modulo 11, and that 11 is prime.
1. Compute the check character for the prefix 4 0 7 2 1 5 3.
Read the worked answer
Apply the weights position by position:
- 1·4 = 4
- 2·0 = 0
- 3·7 = 21
- 4·2 = 8
- 5·1 = 5
- 6·5 = 30
- 7·3 = 21
Sum: 4 + 0 + 21 + 8 + 5 + 30 + 21 = 89.
Reduce modulo 11: 89 = 8·11 + 1, so the residue is 1. Because 1 is not 10, the check character is the digit 1, and the full code is 40721531.
The only trap is reducing the weighted digits before adding; the result is the same here, but the sum-then-reduce route avoids errors when many terms are near 10.
2. Recover the smudged digit in 5 2 ? 1 4 0 6, whose check character is X.
Read the worked answer
Let the unknown digit be d. The weighted sum is
5 + 2·2 + 3d + 4·1 + 5·4 + 6·0 + 7·6 = 5 + 4 + 3d + 4 + 20 + 0 + 42 = 75 + 3d.
A check character X means the residue must be 10 (mod 11). Now 75 = 6·11 + 9, so 75 ≡ 9, giving
3d ≡ 10 − 9 ≡ 1 (mod 11).
Multiply both sides by the inverse of 3 modulo 11, which is 4 because 3·4 = 12 ≡ 1:
d ≡ 4 (mod 11).
Since a digit lies in 0…9 and any two solutions differ by a multiple of 11, d = 4 is the unique admissible answer. Check: 75 + 12 = 87 = 7·11 + 10, residue 10, printed as X. The code reads 5241406X.
3. Show whether swapping two adjacent digits is always detected.
Read the worked answer
Let two positions i and j carry digits di and dj, and swap them. Only those two terms of the weighted sum change:
new − old = (i·dj + j·di) − (i·di + j·dj) = (i − j)(dj − di).
Here i, j ∈ {1,…,7} with i ≠ j, so i − j is one of ±1,…,±6: nonzero modulo 11. Digits differ, so dj − di is one of ±1,…,±9: also nonzero modulo 11. Because 11 is prime, a product of two nonzero residues modulo 11 cannot be 0, so the weighted sum changes modulo 11 and the required check character changes with it. The corrupted code therefore fails verification.
The argument covers every transposition, not only adjacent ones, and the same reasoning shows that any single-digit error is caught, since the change is i·δ with 1 ≤ i ≤ 7 and 1 ≤ |δ| ≤ 9. It does not follow that the scheme is perfect: two errors that compensate modulo 11 can pass, and the weight pattern is public, so a determined forger can still build a valid code.