2 deleted 88 characters in body edited Feb 2 '11 at 0:09 Nellius 56833 silver badges88 bronze badges C# (10194 characters) string I(string i){int s=0,j=0,f;forj=0;for(;j<12;)s+=(i[j]-48)*(++j%2>0j++%2<1?3:1:3);f=10-s%10;return;return i+(f>9?0:f(10-s%10)%10);}  With linebreaks/whitespace for readability: string I(string i) { int s = 0, j = 0, f;0; for (; j < 12; ) s += (i[j] - 48) * (++jj++ % 2 >< 01 ? 31 : 13); f = 10 - s % 10; return i + (f(10 >- 9s ?% 010) :% f10); }  Tested on several ISBNs from books on my shelf, so I know it's working! C# (101 characters) string I(string i){int s=0,j=0,f;for(;j<12;)s+=(i[j]-48)*(++j%2>0?3:1);f=10-s%10;return i+(f>9?0:f);}  With linebreaks/whitespace for readability: string I(string i) { int s = 0, j = 0, f; for (; j < 12; ) s += (i[j] - 48) * (++j % 2 > 0 ? 3 : 1); f = 10 - s % 10; return i + (f > 9 ? 0 : f); }  Tested on several ISBNs from books on my shelf, so I know it's working! C# (94 characters) string I(string i){int s=0,j=0;for(;j<12;)s+=(i[j]-48)*(j++%2<1?1:3);return i+((10-s%10)%10);}  With linebreaks/whitespace for readability: string I(string i) { int s = 0, j = 0; for (; j < 12; ) s += (i[j] - 48) * (j++ % 2 < 1 ? 1 : 3); return i + ((10 - s % 10) % 10); }  Tested on several ISBNs from books on my shelf, so I know it's working! 1 answered Feb 1 '11 at 23:55 Nellius 56833 silver badges88 bronze badges C# (101 characters) string I(string i){int s=0,j=0,f;for(;j<12;)s+=(i[j]-48)*(++j%2>0?3:1);f=10-s%10;return i+(f>9?0:f);}  With linebreaks/whitespace for readability: string I(string i) { int s = 0, j = 0, f; for (; j < 12; ) s += (i[j] - 48) * (++j % 2 > 0 ? 3 : 1); f = 10 - s % 10; return i + (f > 9 ? 0 : f); }  Tested on several ISBNs from books on my shelf, so I know it's working!