Luhn algorithm: Difference between revisions

Content deleted Content added
m Reverted edits by 2400:ADC5:196:8700:8175:396B:2F30:8A01 (talk) to last revision by 141.96.0.23: nonconstructive edits
Tag: Reverted
Line 7:
 
==Description==
i don edit em,,,,,,,
The check digit is computed as follows:
# If the number already contains the check digit, drop that digit to form the "payload". The check digit is most often the last digit.
# With the payload, start from the rightmost digit. Moving left, double the value of every second digit (including the rightmost digit).
# Sum the values of the resulting digits.
# The check digit is calculated by <math>(10 - (s \bmod 10)) \bmod 10</math>, where s is the sum from step 3. This is the smallest number (possibly zero) that must be added to <math>s</math> to make a multiple of 10. Other valid formulas giving the same value are <math>9 - ((s + 9)\bmod 10)</math>, <math>(10 - s)\bmod 10</math>, and <math>10\lceil s/10\rceil - s</math>. Note that the formula <math>(10 - s)\bmod 10</math> will not work in all environments due to differences in how negative numbers are handled by the [[modulo]] operation.
 
=== Example for computing check digit ===
 
Assume an example of an account number 1789372997 (just the "payload", check digit not yet included):