Credit card numbers conform to the
Luhn algorithm, which is just a simple checksum test on the number. What you do is start from the right and double each second digit (1111 becomes 2121), then add them all together, and you should end with a number evenly divisible by ten. If it doesn’t, it’s not a valid credit card number.