Just re-visited this with someone and thought I'd share it.
How can you tell if a credit card # is ""valid""? This only will tell you if the cc # is a real #.
Most credit cards use a checksum algorithm. From right to left, double every other digit starting with the second to last (the last digit is the checksum). Add the digits of the results (18 is really 1+8 or 9). The sum of all the digits must be divisible by 10.
For example, 5499740000000123:
3
2 x 2 = 4
1
0 x 2 = 0
0
0 x 2 = 0
0
0 x 2 = 0
0
0 x 2 = 0
4
7 x 2 = 5 [14] 1 + 4 = 5
9
9 x 2 = 9 [18] 1 + 8 = 9
4
5 x 2 = 1 [10] 1 + 0 = 1
-----
40 / 10 = 4