Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #49 Aug 22 2024 15:44:18
%S 0,5,7,6,3,8,2,0,9,1,9,3,1,2,5,0,6,8,4,7,4,5,7,6,3,8,2,0,9,1,1,7,9,8,
%T 0,5,4,2,6,3,8,2,0,1,9,4,5,7,3,6,5,4,2,3,6,1,7,9,0,8,7,1,4,0,8,3,9,6,
%U 2,5,3,9,6,5,2,7,1,4,8,0,0,6,8,7,4,9,3,1
%N a(n) is the Verhoeff check digit for n.
%C The Verhoeff checksum is a single-digit error-detecting code.
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Dihedral_group">Dihedral group</a>.
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Verhoeff_algorithm">Verhoeff algorithm</a>.
%o (Python)
%o d_table = [
%o [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],[1, 2, 3, 4, 0, 6, 7, 8, 9, 5],
%o [2, 3, 4, 0, 1, 7, 8, 9, 5, 6],[3, 4, 0, 1, 2, 8, 9, 5, 6, 7],
%o [4, 0, 1, 2, 3, 9, 5, 6, 7, 8],[5, 9, 8, 7, 6, 0, 4, 3, 2, 1],
%o [6, 5, 9, 8, 7, 1, 0, 4, 3, 2],[7, 6, 5, 9, 8, 2, 1, 0, 4, 3],
%o [8, 7, 6, 5, 9, 3, 2, 1, 0, 4],[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
%o ]
%o p_table = [
%o [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],[1, 5, 7, 6, 2, 8, 3, 0, 9, 4],
%o [5, 8, 0, 3, 7, 9, 6, 1, 4, 2],[8, 9, 1, 6, 0, 4, 3, 5, 2, 7],
%o [9, 4, 5, 3, 1, 2, 6, 8, 7, 0],[4, 2, 8, 6, 5, 7, 3, 9, 0, 1],
%o [2, 7, 9, 3, 8, 0, 6, 4, 1, 5],[7, 0, 4, 6, 9, 1, 3, 2, 5, 8]
%o ]
%o j_table = [0, 4, 3, 2, 1, 5, 6, 7, 8, 9]
%o def a(n):
%o c, ds = 0, list(map(int, str(n*10)[::-1]))
%o for i, d in enumerate(ds):
%o c = d_table[c][p_table[i % 8][d]]
%o return j_table[c]
%o print([a(n) for n in range(0, 55)])
%Y Cf. A093018.
%K nonn,easy,base
%O 0,2
%A _DarĂo Clavijo_, Jul 25 2024