Content deleted Content added
m Correcting formatting |
No edit summary |
||
Line 7:
:Finally, as for creating the check digit, I don't think that code is what we want. The question is: what digit should I add to a particular number? If we assume that we will get a k digit number, and will add the check-digit as the least-significant number and return a k+1 digit number, I say do the following: Suppose check-digit(X) returns the checksum of X, a number 0 through 9, then the algorithm is: return (10 X + (10 - check-digit(10 X))). Details depend on the input representation of X. --[[User:Ozga|Ozga]] 14:42, 14 December 2006 (UTC)
I think if you factor your equation above and adjust for the modulo implementation I use, you'll come up the same thing, unless you are mistaken. I have double checked the last part of the algorithm. Essentially the algorithm figures out what the Luhn sum would be for the number sequence with out the check number. Then it determines what mod 10 of that number is. If mod 10 is 0, then the number already passes, so the check is 0. Otherwise, a value needs to be added so that the sum + check mod 10 will be zero. Therefore, we do 10 minus the sum mod 10 to determine the check digit. If you're unhappy with the logical defense of last step, you can observe it empirically by compiling the test program here: [http://data.zx2c4.com/Credit.cs]. I have added a new section below regarding the improper addition of the php and vb algorithms. [[User:Zx2c4|ZX2C4]] 08:14, 6 January 2007 (UTC)
== Removal of VB and PHP Algorithms ==
|