# Damm Algorithm

In error detection, the Damm algorithm is a check digit algorithm that detects all single-digit errors and all adjacent transposition errors. It was presented by H. Michael Damm in 2004. Its essential part is a quasigroup of order 10 (i.e. having a 10×10 Latin square as operation table) with the special feature of being totally anti-symmetric. Damm revealed several methods to create such TA-quasigroups of order 10 and gave some examples in his doctoral dissertation. With this, Damm also disproved an old conjecture that TA-quasigroups of order 10 do not exist.

` ````
public static char CheckSum(string number)
{
const string table = "0317598642709215486342068713591750983426612304597836742095815869720134894536201794386172052581436790";
char interim = '0';
for (int i = 0; i < number.Length; ++i)
{
if ((number[i] - '0') > 9)
return '-';
interim = table[(number[i] - '0') + (interim - '0') * 10];
}
return interim;
}
public static bool Validate(string number)
{
return CheckSum(number) == '0';
}
```

### Example

` ````
char c = CheckSum("572");
bool isValid = Validate("5724");
```

### Output

` ````
c: 4
isValid: true
```