Good news! The world’s largest workbook is free and available for anyone who knows where to find it. That workbook is full of real-world math practice problems that use addition, subtraction, multiplication and division.

The workbook is basically all the **UPC (Universal Product Code)** product identifiers in the known universe.

UPC barcodes are everywhere. We can find UPC barcodes in the house, in the supermarket, and pretty much any place that you may find **consumer packaged goods (CPG)**.

In the CPG industry, UPC barcodes are essential for managing inventory through automated scanning. The beeping sound that you hear at the grocery checkout counter represents millions of dollars that have been invested in supply chain management and customer service.

That same beeping sound confirms the completion of a validation process, where 12 UPC numerical digits (ranging from 0 to 9) are used to make calculations using a specified algorithm.

An **algorithm** is a series of logical steps that generates a specific and predictable solution. In this case, the algorithm is calculating the UPC check digit, which is an industry standard for validation.

From a broader perspective, algorithms are very important in computer science, business analytics, and supply chain management. We can use algorithms to help manage costs and add opportunities for new revenue streams.

## UPC Check Digit Algorithm

There are many types of UPC barcodes.

In this activity, we will focus on the UPC-A barcode and its corresponding check digit algorithm.

**A valid UPC-A barcode has exactly 12 digits.** You may see barcodes with only 11 digits recorded for product inventory. If you see 11-digit barcode numbers, simply add a zero to the beginning of the UPC-A character sequence.

We find the UPC-A check digit by applying an algorithm that uses the first 11 digits of the UPC barcode. The check digit should equal the final digit.

- Here is the algorithm for calculating the UPC check digit:
**Step 1:**Add the odd-indexed digits. Multiply that first sum by 3.**Step 2:**Add the even-indexed digits for a second sum.**Step 3:**Add both sums from Step 1 and Step 2. Divide that combined sum by 10. Subtract the remainder from 10. The difference is the check digit. If the remainder is zero, the check digit is zero.

Let us use an example to better understand how this algorithm works in the computer whenever the UPC barcode is scanned and validated. Download a blank worksheet, and use it to follow along during the walkthrough below.

## Worksheets

## UPC Barcode Check Digit Walkthrough

We will use the following UPC in this example:

`040000527152`

This UPC is probably more familiar when it is printed on CPG products in its iconic barcode visual representation:

Interestingly, you can create UPC barcodes in Wolfram Alpha.

**Sample Wolfram Alpha input**

`UPC 040000527152`

To begin, enter all the UPC digits in the order they appear. The digits are indexed by their position in the UPC character sequence. There are odd-indexed digits, and there are even-indexed digits.

1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
---|---|---|---|---|---|---|---|---|---|---|---|

0 | 4 | 0 | 0 | 0 | 0 | 5 | 2 | 7 | 1 | 5 | 2 |

Remember, we are only using the first 11 digits for this calculation. The final digit (in the 12th position) should always match the check digit for the UPC-A barcode to be considered valid.

**Step 1:** Add all the odd-indexed digits. Multiply the sum by 3.

1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
---|---|---|---|---|---|---|---|---|---|---|---|

0 | 0 | 0 | 5 | 7 | 5 |

`3A = 3 * (0 + 0 + 0 + 5 + 7 + 5)`

`3A = 3 * 17 = 51 `

**Step 2:** Add all the even-indexed digits (except the last digit).

1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
---|---|---|---|---|---|---|---|---|---|---|---|

4 | 0 | 0 | 2 | 1 |

`B = (4 + 0 + 0 + 2 + 1) `

`B = 7 `

**Step 3: **Combine both sums. Find the “modulo 10” of that result. Subtract the “module 10” value (the remainder) from 10 to get the check digit. If the remainder is 0, the check digit is 0. **The check digit should equal the final digit of the UPC-A character sequence.**

`3A + B = ( 51 + 7 ) = 58`

`check digit `

`= 10 - (3A + B) modulo 10`

`= 10 - (58 modulo 10)`

`= 10 - 8 = 2`

**CCSS.MATH.CONTENT.4.OA.A.3:** Solve multistep word problems posed with whole numbers and having whole-number answers using the four operations, including problems in which remainders must be interpreted.

**NOTE: **Markdown tables were generated with Google Sheets using MarkdownTableMaker, another Bitwise Thermodynamics project.

## Discussion

All four operations of arithmetic are used in this math practice activity. Addition, subtraction, multiplication, and division are used to calculate the check digit.

In addition to the four basic arithmetic operations, we had the opportunity to use a specialized operation called the **modulo operation**. The modulo operation (or function) focuses on the remainder of the division operation instead of the quotient. In other words, modulo is specifically asking the amount leftover after the division operation is completed.

Modulo is very useful for determining properties of numbers. For example, even numbers have a “modulo 2” equal to zero, while odd numbers have a “modulo 2” equal to one.

In computer programming, this modulo operation is often used in algorithms related to the processing and rendering of consecutive data records (e.g., positions of a character sequence, rows in a table, etc.).

In this math activity, we used “modulo 10” to help find the check digit. Computational platforms (such as Wolfram Alpha), search engines and some smart speakers can provide modulo operation results.

*Sample Wolfram Alpha input*`88 modulo 2`

OR `55 mod 2`

OR `55 % 10`

## Conclusion

UPCs are ubiquitous, which provides unlimited opportunity for math practice on shopping trips or activities involving pantry inventory. Every CPG package in the grocery store is now part of the world’s largest math workbook. The math problems are free and the added math practice will pay off with improved recall of multiplication facts.

Every UPC is a math practice problem with the “answer” provided. However, every UPC must be checked because some UPCs *fail the validation process*, which may cause issues during inventory audits and customer checkout (when the cashier calls for a “price check”).

In addition to the worksheets in this activity, personal math journals are great places to record interesting UPC barcodes found for future reference.

**MathForWork** delivers distributed learning systems, instruction support, and test preparation for all learners. Learn more at MATHFORWORK.COM. MathForWork is a Bitwise Thermodynamics project.