Question
Suppose you are given a 7 digit number which is a UPC. Provethat if a mistake is made when scanning the number, causing onedigit to be read incorrectly, then you will be able to tell that anerror has been made.
Extra information.
A number is a Universal Product Code (UPC) if its last digitagrees with the following computations:
• The sum of the odd position digits (not including the last) isM. That is we add the first digit to the third digit to the fifthdigit 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 lastone:
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 beUPC. That is 1231245 is a UPC