Talk:Luhn algorithm: Difference between revisions

Content deleted Content added
pseudocode: new section
GWT45 (talk | contribs)
Tags: Mobile edit Mobile app edit iOS app edit
Line 314:
int parity := (nDigits-2)modulus 2
First, there is no such operation as "modulus". The operation is called "modulo" or "mod" for short. The "modulus" is the second operand in a mod operation (in this case, 2) not the operation or the result of the operation. Second, unless card numbers can have no digits other than a check digit, "(nDigits-2) mod 2" is equal to "nDigits mod 2". Third, type declarations and casts are undesirable in pseudocode unless the meaning of the code is unclear without them. [[User:Zero0000|Zero]]<sup><small>[[User_talk:Zero0000|talk]]</small></sup> 05:58, 7 October 2022 (UTC)
 
== One alternative formula is wrong ==
 
The formula 10[s/10] -s is wrong as written. The use of integer math is implied, for if fractional values are allowed, the formula is zero for all s. With internet arithmetic and given example where’s=67, the formula gives -7, not the correct answer of 3.
I would suggest it be r)e-written as
10 + { INT(10[s/10])- s}
Or perhaps better
10-{ s - INT( 10[s/10])}
This Alternative formula gives 3, but I have not carefully checked that it agrees with Luhn’s original formula.
Alternatively, just delete that line in the article. [[User:GWT45|GWT45]] ([[User talk:GWT45|talk]]) 04:10, 6 February 2023 (UTC)