Verhoeff Algorithm - Algorithm

Algorithm

Using the above tables, the following procedure will perform the Verhoeff checksum calculation on a number.

  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 d(c, p(i, ni)).

The original number has a valid check digit if and only if c = 0. If the original number ends in a zero (i.e., n0 = 0), then inv(c) is the proper value to use as the check digit in place of the final zero.

Read more about this topic:  Verhoeff Algorithm