FazBrowse Wikipedia Viewer | Main Page |
Search Wikipedia:
|
Viewing: https://en.wikipedia.org/wiki/Verhoeff_algorithm

Verhoeff algorithm

Contents
Description
Examples
External links

The Verhoeff algorithm is a checksum for error detection first published by Dutch mathematician Jacobus Verhoeff in 1969. It was the first decimal check digit algorithm that detects all single-digit errors, and all transposition errors involving two adjacent digits, which was at the time thought impossible with such a code.

The method was independently discovered by H. Peter Gumm in 1985, this time including a formal proof and an extension to any base.

aa → bb), jump transpositions (aba → cbc). Additionally there are omitted and added digits. Although the frequencies of some of these kinds of errors might be small, some codes might be immune to them in addition to the primary goals of detecting all singles and transpositions.

The phonetic errors in particular showed linguistic effects, because in Dutch, numbers are typically read in pairs; and also while 50 sounds similar to 15 in Dutch, 80 does not sound like 18.

Taking six-digit numbers as an example, Verhoeff reported the following classification of the errors:.

Digits in error Classification Count Frequency
1Transcription9,57479.05%
2Transpositions1,23710.21%
Twins670.55%
Phonetic590.49%
Other adjacent2321.92%
Jump transpositions990.82%
Jump Twins350.29%
Other jump errors430.36%
Other980.81%
31691.40%
41180.97%
52191.81%
61621.34%
Total12,112

Description

edit

The general idea of the algorithm is to represent each of the digits (0 through 9) as elements of the dihedral group D5. That is, map digits to D5, manipulate these, then map back into digits. Let this mapping be 5</sub>"}},"i":0}}]}'>m : [0, 9] → D5

f : D5 → D5

f2(r3)=r3 since c=(∏n=1kfn(ak+1−n))−1

For example the check digit for 942 is 7. To verify this, use the mapping to D5 and insert into the LHS of the previous equation

r2s⋅r2s⋅r2s⋅r2s=e

This is the same reflection being iteratively multiplied. Use that reflections are their own inverse.

d k
0 1 2 3 4 5 6 7 8 9
j 0 0123456789
1 1234067895
2 2340178956
3 3401289567
4 4012395678
5 5987604321
6 6598710432
7 7659821043
8 8765932104
9 9876543210
j inv(j)
0 0
1 4
2 3
3 2
4 1
5 5
6 6
7 7
8 8
9 9
p num
0 1 2 3 4 5 6 7 8 9
pos (mod 8)
0 0123456789
1 1576283094
2 5803796142
3 8916043527
4 9453126870
5 4286573901
6 2793806415
7 7046913258

The first table, d, is based on multiplication in the dihedral group D5. and is simply the Cayley table of the group. Note that this group is not commutative, that is, for some values of j and k, d(j, inv(j)) = 0.

The permutation table p applies a permutation to each digit based on its position in the number. This is actually a single permutation p(i + j, n) = p(i, p(j, n)).

The Verhoeff checksum calculation is performed as follows:

  1. Create an array n out of the individual digits of the number, taken from right to left (rightmost digit is n0, etc.).
  2. Initialize the checksum c to zero.
  3. For each index i of the array n, starting at zero, replace c with c = 0.

    To generate a check digit, append a 0, perform the calculation: the correct check digit is inv(c).

    Examples

    edit
    i</sub>''\n! style=\"background:#ffc\" | ''p''(''i'', ''n<sub>i</sub>'')\n! style=\"background:#ffc\" | ''c''\n|-\n|0||0||0||0\n|-\n|1||6||3||3\n|-\n|2||3||3||1\n|-\n|3||2||1||2\n|}\n''c'' is 2, so the check digit is inv(2), which is 3.\n",{"template":{"target":{"wt":"col-2","href":"./Template:Col-2"},"params":{},"i":2}},"\n'''Validate''' the check digit in 2363:\n{| class=\"wikitable\" style=\"text-align:center\"\n|-\n! style=\"background:#ffc\" | ''i''\n! style=\"background:#ffc\" | ''n<sub>i</sub>''\n! style=\"background:#ffc\" | ''p''(''i'', ''n<sub>i</sub>'')\n! style=\"background:#ffc\" | ''c''\n|-\n|0||3||3||3\n|-\n|1||6||3||1\n|-\n|2||3||3||4\n|-\n|3||2||1||0\n|}\n''c'' is zero, so the check is correct.\n",{"template":{"target":{"wt":"col-end","href":"./Template:Col-end"},"params":{},"i":3}}]}'>Kirtland, Joseph (2001). "5. Group Theory and the Verhoeff Check Digit Scheme". Identification Numbers and Check Digit Schemes. Mathematical Association of America. p. 153. ISBN 0-88385-720-0.
  4. ↑ Gumm, H. (January 1985). "A new class of check-digit methods for arbitrary number systems (Corresp.)". IEEE Transactions on Information Theory. 31 (1): 102–105. doi:10.1109/TIT.1985.1056991.
  5. ↑ "EIMI 2010 Proceedings" (PDF). Freudenthal Institute, Utrecht University. Lisbon, Portugal: Educational Interfaces between Mathematics and Industry. 2010. p. 128. doi:10.1007/978-3-319-02270-3. Archived from the original (PDF) on 16 May 2024. Retrieved 13 September 2025.
  6. ↑ "Check digit computation". docs.snomed.org. SNOMED International. Archived from the original (Official Documentation) on 13 September 2025. Retrieved 13 September 2025.

External links

edit
Wikibooks has a book on the topic of: Algorithm_Implementation/Checksums/Verhoeff_Algorithm

View original on Wikipedia | Back | FazBrowse Home