What is the Damm algorithm?

The Damm algorithm adds a check digit to a number so that typing mistakes get caught. H. Michael Damm published it in 2004. Like the Verhoeff algorithm, it catches every single wrong digit and every swap of two neighboring digits, but it needs only one lookup table, a grid of 10 by 10 digits.

Tool description

Set the Length, the number of digits including the check digit, and a random number appears under Damm number, ready to copy. It starts with 10 digits. Every change to the length makes a new number, and Generate makes another one of the same length.

All digits except the last are random, and the last one is the Damm check digit for them, so every number passes a Damm check. A number can start with 0.

Features

  • Random numbers of the length you set, each ending in a correct Damm check digit
  • A new number every time you change the length or press Generate
  • A copy button for pasting the number into a form or a test

How the check digit is calculated

Start with an interim digit of 0. For each digit of the number, find the row of the interim digit and the column of the digit in the table below. The cell there is the new interim digit, and the last one is the check digit.

    0 1 2 3 4 5 6 7 8 9
0   0 3 1 7 5 9 8 6 4 2
1   7 0 9 2 1 5 4 8 6 3
2   4 2 0 6 8 7 1 3 5 9
3   1 7 5 0 9 8 3 4 2 6
4   6 1 2 3 0 4 5 9 7 8
5   3 6 7 4 2 0 9 5 8 1
6   5 8 6 9 7 2 0 1 3 4
7   8 9 4 5 3 6 2 0 1 7
8   9 4 3 8 6 1 7 2 0 5
9   2 5 8 1 4 3 6 7 9 0

For 123: row 0, column 1 gives 3. Row 3, column 2 gives 5. Row 5, column 3 gives 4. So the check digit is 4, and the full number is 1234. Run 1234 through the same steps and you end at 0, which is how a validator knows the number is right.

Good to know

  • The digits come from Math.random, which isn't meant for secrets, so don't use the numbers as PINs or codes.
  • To check a number, use the Damm number validator.