Nuacht

All mainstream credit card numbers obey a mathematical trick designed to catch the most common typos. It’s called the Luhn ...
Credit card issuers first assign the account numbers and then compute steps one through three of the Luhn algorithm to determine the appropriate check digit.
If they don’t, the number is invalid. That’s why the last digit in the string is called the “check digit,” which completes the algorithm so it is divisible by 10.
The Luhn algorithm uses modulo-10 mathematics. To calculate the check digit, multiply every even-position digit (when counted from the right) in the number by two.