The last digit on a credit card number is the "checksum" number, which uses the above algorithm to validate the card. The concept is discussed at Wikipedia:
A checksum or hash sum is a fixed-size datum computed from an arbitrary block of digital data for the purpose of detecting accidental errors that may have been introduced during its transmission or storage. The integrity of the data can be checked at any later time by recomputing the checksum and comparing it with the stored one. If the checksums match, the data was almost certainly not altered.Image cropped from a longer infographic about credit card numbers at Fishki.