There are many places in our lives where we meet identification numbers; for example, passports, bank accounts, credit cards, ISBN book numbers, and so on. Each identification number obeys a rule which makes it easy to check (most of the time) whether the number has been copied correctly or not and for this reason they are also called check codes. Here are some of the methods for checking the validity of these numbers. They use modulus or clock arithmetic.

Which of the following are valid identification numbers? The rules for each type are given below. US Money Order: 123-123-123-45 Airline tickets: 123456780 Universal Product Code: 654321123456 Credit card: 1723-1001-2065-1098 ISBN number: 0 5215 3612 4 US banks: 07100013

US Postal Service Money Order: This is an eleven digit number using digits 1,2,...9 where the sum of the first ten digits is congruent to the eleventh digit modulo 9. That is a1a2a11 where     a1+ …+a10a11 mod 9. The last digit is called the check digit. For example 23548762912 is a valid number because the first ten digits add up to 47 which is congruent to 2 mod 9.

Airline tickets: This number can be any length. It uses the digits 0 to 9 and the last digit is a check digit. The number formed by omitting the check digit must be congruent to the check digit modulo 7. That is     a1anan+1 where     a1a2anan+1 mod 7. For example 2943739573 is a valid number because 294373957 ≡ 3 mod 7.

Universal Product Code: This is a twelve digit number (a,b1,b2,b3,b4,b5,c1,c2,c3,c5,c5,d) using the digits 0 to 9, where a is the category of the goods (clothes, food,...), b1,…,b5 is the manufacturer's code c1,…,c5 is the code for the product, d is the check digit. If we rewrite this type of identification code in the form (a1,a2,…, a12), then these codes must satisfy the following condition:
3(a1+a3+…+ a11) + (a2+a4+…+a12) ≡ 0  mod  10.
Note that if a number N is congruent to zero mod 10 it means that N is a multiple of 10. For example 582039827198 is a valid code because 3(5+2+3+8+7+9)+(8+0+9+2+1+8)=130.

All Major Credit Cards: These identification codes     a1a16 have sixteen digits using digits 0 to 9, where α+ β+ γ ≡ 0 mod 10 and where
α
= 2(a1 + a3 + …+ a15),
β
= the number of aj with j odd and aj > 4,
γ
= a2 + a4 + …+a16.
For example 6356 0125 0327 9616 is a valid code because α = 2(6+5+0+2+0+2+9+1)=50, β = 3, γ = (3+6+1+5+3+7+6+6) = 37 and α+β+γ = 90.

ISBN Numbers: Books have ten digit identification numbers a1a10 using the digits 0 to 9 where
10a1+9a2+8a3+…+3a8+2a9+a10 ≡ 0  mod 11.
Sometimes this forces the check-digit a10 to be 10; as this would then give an eleven digit number the publishers use X instead of 10. For example, to check
0 7167 2393 X we calculate 0+63+8+42+42+10+12+27+6=210 so, as the check digit is 10 which makes the total 220 (a multiple of 11) we know this is a valid ISBN number.

US Banks: These are nine digit identification numbers a1a2a9 using the digits 0 to 9 where 7a1 + 3a2 + 9a3 + 7a4 + 3a5 + 9a6 + 7a7 + 3a8a9 mod 10. For example 123456780 is a valid US bank identification number.

Further information of check codes can be found in this article written by Emily Dixon.