I'm not sure how true it is. I dint verify.. You can check it out!
Luhn algorithm - Wikipedia, the free encyclopedia
Luhn algorithm
Now, the question is how can we check whether a given credit card number
is valid. The algorithm involved in this checking is called Luhn
algorithm (AKA Sum10 algorithm, AFAIK). Consider a number, say,
5168254236021548. To understand if this is a valid cc#, you should
follow 4 easy guidelines:
1. Starting from the leftmost digit, we simply multiply alternating
numbers by two. i.e., we multiply shown bold numbers by two:
5168254236021548
5 * 2 = 10
6 * 2 = 12
2 * 2 = 4
4 * 2 = 8
3 * 2 = 6
0 * 2 = 0
1 * 2 = 2
4 * 2 = 8
2. Add the separate digits of all the products, as follows:
1 + 0 + 1 + 2 + 4 + 8 + 6 + 0 + 2 + 8 = 32
3. Add the unaffected digits to the product, i.e.,
1 + 8 + 5 + 2 + 6 + 2 + 5 + 8 = 37
4. Add the result of the step 2 and 3 and divide it by 10
32 + 37 = 69
69 % 10 = 9
5. If the answer is 0, this is a valid cc#, otherwise, it is not!
So 5168254236021548 is an invalid cc# (since 69 % 10 is 9 not 0).
Luhn algorithm - Wikipedia, the free encyclopedia
Luhn algorithm
Now, the question is how can we check whether a given credit card number
is valid. The algorithm involved in this checking is called Luhn
algorithm (AKA Sum10 algorithm, AFAIK). Consider a number, say,
5168254236021548. To understand if this is a valid cc#, you should
follow 4 easy guidelines:
1. Starting from the leftmost digit, we simply multiply alternating
numbers by two. i.e., we multiply shown bold numbers by two:
5168254236021548
5 * 2 = 10
6 * 2 = 12
2 * 2 = 4
4 * 2 = 8
3 * 2 = 6
0 * 2 = 0
1 * 2 = 2
4 * 2 = 8
2. Add the separate digits of all the products, as follows:
1 + 0 + 1 + 2 + 4 + 8 + 6 + 0 + 2 + 8 = 32
3. Add the unaffected digits to the product, i.e.,
1 + 8 + 5 + 2 + 6 + 2 + 5 + 8 = 37
4. Add the result of the step 2 and 3 and divide it by 10
32 + 37 = 69
69 % 10 = 9
5. If the answer is 0, this is a valid cc#, otherwise, it is not!
So 5168254236021548 is an invalid cc# (since 69 % 10 is 9 not 0).