Universal Product Code

The barcodes are ubiquitous. According the readily available statistics, about half of the United States population were born after the barcodes have been introduced in 1973.

The original and primary barcode used in the USA is a machine readable representation of the UPC which stands for the Universal Product Code. The UPC and the barcodes were designed for the grocery industry. Because of the large number of items normally "checked-out" at the grocery store, the cashier errors in identifying the products were frequent, caused check-out delays and affected the industry's bottom line. The barcode was a response to the need to automate the check-out process. It was invented by George J. Laurer, an IBM employee, and adopted by the grocery industry on April 3, 1973.

The original UPC code is also known as UPC-A or UCC-12, the latter to indicate its 12-digit size. (UCC is an abbreviation for the Uniform Code Council, a not-for-profit organization responsible in part for the issuance of the UPC codes.)

The twelve UPC-A digits are comprised of three groups: a 6-digit company prefix (assigned by by the UCC to a specific manufacturer), a 5-digit product code (assigned by a responsible person within the company), and 1 check digit (calculated according to an algorithm discussed next).

Assume the 12 digits are d1, d2, d3, ..., d11, d12. In a valid UPC barcode, d12 is so selected as to make the following identity true:

(1) 3×d1 + d2 + 3×d3 + d4 + ... + 3×d11 + d12 = 0 (mod 10).

To put it differently, let Sodd and Seven be the sums of the digits in the odd and even positions, starting with 1. Then, for a valid UPC-12 code

(1') 3×Sodd + Seven = 0 (mod 10).

As the common symbolism suggests, the sum in (1) equals 0 modulo 10. In other words, it is divisible by 10.

In the applet below, the first 11 digits of the code are clickable and hence are modifiable. The last digit is determined automatically, according to (1). (The fact that UPC-A is based on (1) serves as the basis to a computer magic trick.)

If you are reading this, your browser is not set to run Java applets. Try IE11 or Safari and declare the site https://www.cut-the-knot.org as trusted in the Java setup.

Universal Product Code

What if applet does not run?

It can't be overemphasized that the UPC-A code is a 12 digit string (often said to be a number) that on retail products accompanies its own barcode representation. But there are other encodings based or extending UPC (e.g., EAN-13) that have machine readable barcode representation.

The actual process of conversion of an UPC-A string into a barcode is explained elsewhere.


  1. E. B. Burger, M. Starbird, The Heart of Mathematics, Key College Publishing, 2000, pp. 89-90

|Contact| |Front page| |Contents| |Algebra|

Copyright © 1996-2018 Alexander Bogomolny