In: Advanced Math
Question
Suppose you are given a 7 digit number which is a UPC. Prove that if a mistake is made when scanning the number, causing one digit to be read incorrectly, then you will be able to tell that an error has been made.
Extra information.
A number is a Universal Product Code (UPC) if its last digit agrees with the following computations:
• The sum of the odd position digits (not including the last) is M. That is we add the first digit to the third digit to the fifth digit etc.
• The sum of the even position digits (not including the last) is N. •
c = (3M + N)%10.
• If c = 0 then the check digit is 0.
• If c 6= 0, then the check digit is 10 − c.
An example with number 1231242.
1) you add all odd-positioned digits except the last one:
M=1+3+2=6
2) add all even positioned digits, not including the last one:
N=2+1+4=7
3) c=(3M+N)%10=(6*3+7)%10=5
4) the check digit is 10-5=5
So 1231242 is not a UPC.
However, if we change the last digit to be 5, then it will be UPC. That is 1231245 is a UPC
The UPC includes a check digit to detect common data entry errors.
For example , UPC-A code choose the check digit X12 to satisfy the check digit equation:
( 3X1 + X2 + 3X3 + X4 + 3X5 + X6 + 3X7 + X8 + 3X9 + X10 + 3X11 + X12 ) = 0 ( mod 10)
If an entered code does not satisfy the equation , then it is not a valid UPC-A