A374967 a(n) is the Verhoeff check digit for n.
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, 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, 2, 5, 3, 9, 6, 5, 2, 7, 1, 4, 8, 0, 0, 6, 8, 7, 4, 9, 3, 1
Offset: 0
Links
- J. Verhoeff, Error Detecting Decimal Codes Mathematical Centre Tracts, 29.
- Wikipedia, Dihedral group.
- Wikipedia, Verhoeff algorithm.
Crossrefs
Cf. A093018.
Programs
-
Python
d_table = [ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],[1, 2, 3, 4, 0, 6, 7, 8, 9, 5], [2, 3, 4, 0, 1, 7, 8, 9, 5, 6],[3, 4, 0, 1, 2, 8, 9, 5, 6, 7], [4, 0, 1, 2, 3, 9, 5, 6, 7, 8],[5, 9, 8, 7, 6, 0, 4, 3, 2, 1], [6, 5, 9, 8, 7, 1, 0, 4, 3, 2],[7, 6, 5, 9, 8, 2, 1, 0, 4, 3], [8, 7, 6, 5, 9, 3, 2, 1, 0, 4],[9, 8, 7, 6, 5, 4, 3, 2, 1, 0] ] p_table = [ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],[1, 5, 7, 6, 2, 8, 3, 0, 9, 4], [5, 8, 0, 3, 7, 9, 6, 1, 4, 2],[8, 9, 1, 6, 0, 4, 3, 5, 2, 7], [9, 4, 5, 3, 1, 2, 6, 8, 7, 0],[4, 2, 8, 6, 5, 7, 3, 9, 0, 1], [2, 7, 9, 3, 8, 0, 6, 4, 1, 5],[7, 0, 4, 6, 9, 1, 3, 2, 5, 8] ] j_table = [0, 4, 3, 2, 1, 5, 6, 7, 8, 9] def a(n): c, ds = 0, list(map(int, str(n*10)[::-1])) for i, d in enumerate(ds): c = d_table[c][p_table[i % 8][d]] return j_table[c] print([a(n) for n in range(0, 55)])
Comments