cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A237042 UPC check digit for n.

This page as a plain text file.
%I A237042 #18 Feb 16 2025 08:33:21
%S A237042 7,4,1,8,5,2,9,6,3,9,6,3,0,7,4,1,8,5,2,8,5,2,9,6,3,0,7,4,1,7,4,1,8,5,
%T A237042 2,9,6,3,0,6,3,0,7,4,1,8,5,2,9,5,2,9,6,3,0,7,4,1,8,4,1,8,5,2,9,6,3,0,
%U A237042 7,3,0,7,4,1,8,5,2,9,6,2,9,6,3,0,7,4,1,8,5,1,8,5,2,9,6,3
%N A237042 UPC check digit for n.
%C A237042 The UPC check digit is calculated much like a base 10 digital root, except that the digits in the ones place, hundreds place, ten thousands place, etc., are multiplied by 3, before the final step of multiplying the whole sum by -1 prior to taking it modulo 10. Thus the UPC check digit gives the impression of advancing in steps of 7 with each increment of 1 except most of the times when the last digit of n goes from 9 to 0.
%D A237042 David Salomon, Coding for Data and Computer Communications. New York: Springer (2006): 41 - 42.
%H A237042 GS1, <a href="http://www.gs1.org/barcodes/support/check_digit_calculator">Check Digit Calculator</a>.
%H A237042 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/UPC.html">UPC</a>.
%F A237042 a(n) = -( (Sum_{i=1..floor(L/2)} d(2i-1)) + 3*(Sum_{j=0..floor(L/2)} d(2j)) ) mod 10, where L is how many digits n has, d(L - 1) is the most significant digit of n, ..., and d(0) is the ones place digit.
%e A237042 a(13) = 0 because 1 * 1 + 3 * 3 = 10, giving a check digit of 0.
%e A237042 a(14) = 7 because 1 * 1 + 4 * 3 = 13, and -13 = 7 mod 10.
%e A237042 a(15) = 4 because 1 * 1 + 5 * 3 = 16, and -16 = 4 mod 10.
%o A237042 (PARI) a(n) = vecsum(digits(n,100)*31\-10) % 10; \\ _Kevin Ryde_, Oct 03 2023
%Y A237042 Cf. A231963, A144468.
%K A237042 nonn,easy,base
%O A237042 1,1
%A A237042 _Alonso del Arte_, Feb 02 2014