In: Advanced Math
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.
(a) Check whenever 1928467 is a UPC.
(b) 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. Hint: use results from question 2.
(c) Find an example of two 7-digit UPCs that have equal last digits, and disagree with each other at exactly two of the other digits numbers.
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 an UPC.
However if we change the last digit to be 5, then it will be UPC. That is 1231245 is a UPC