Modulo 11 is a great way to check a checksum and is famous for being used in ISBN 10. Nearly every book you have seen has this feature! So how do we use mod 11?
Let us take a simple example.
Let us take a simple example.
Number to check |
1 |
2 |
3 |
4 |
3 |
This is a 4 digit number with a checksum at the end. The first step is to lay it out, so that we can multiply the numbers. (Note how the multiplier goes from RIGHT to LEFT)
Step 1 - Numbers to calculate | 1 | 2 | 3 | 4 |
Step 2 - Multipliers | 5 | 4 | 3 | 2 |
Step 3 Multiply | 5 | 8 | 9 | 8 |
Step 4: We then add it altogether: 5+8+9+8 = 30
Step 5: Use Modulo 11. In Python that's 30%11 = 8
Step 6: Finally 11 - remainder, so that's 11-8 = 3
Exercise 1: Code this up in Python
Hint: This is much easier, if you do a separate variable for each number.
Exercise 2: Check out your solution against this spreadsheet.
Submit here>>
Hint: This is much easier, if you do a separate variable for each number.
Exercise 2: Check out your solution against this spreadsheet.
Submit here>>
EXTENSION: Dealing with 10 & 11
One way to deal with these numbers, is to simply never use them when generating codes. However that is not a good solution!
In ISBN 10
If the result is 10 this becomes X
If the result is 11 this becomes 0
If you would like, then you can have a go at the ISBN 10 challenge you can find More details here>>
In ISBN 10
If the result is 10 this becomes X
If the result is 11 this becomes 0
If you would like, then you can have a go at the ISBN 10 challenge you can find More details here>>