Talk:Luhn algorithm: Difference between revisions

Content deleted Content added
nope: remove my oops
pseudocode: new section
Line 308:
 
The sentence "The check digit is calculated by 10 - (s mod 10)." is not correct. If 's' is a multiple of 10 then the formula result is 10, which is not a digit. To correct this, the sentence should be updated to say "The check digit is calculated by (10 - (s mod 10)) mod 10.". <!-- Template:Unsigned IP --><small class="autosigned">—&nbsp;Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/64.231.116.243|64.231.116.243]] ([[User talk:64.231.116.243#top|talk]]) 02:13, 20 June 2022 (UTC)</small> <!--Autosigned by SineBot-->
 
== pseudocode ==
 
Three comments on the pseudocode:
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)