public static char GetChecksum(string text) { int mul = 3; int total = 0; for (int k = text.Length - 1; k >= 0; --k) { int n = text[k] - '0'; total += mul * n; mul ^= 2; } return (char)(((10 - (total % 10)) % 10) + '0'); }