// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; namespace E { public class Program { public static char CheckDigit(string fik) { int res = 0; for(int i = 0; i < 14; i++) { int val = int.Parse(fik.Substring(i, 1)) * (i % 2 == 0 ? 1 : 2); if(val > 9) { val = val / 10 + val % 10; } res += val; } res = res % 10; res = 10 - res; if(res > 9) { res = 0; } return res.ToString()[0]; } public static void Main(string[] args) { Console.WriteLine(CheckDigit("01234567890986")); } } }