credit card number validation
credit card number validation
Step 1. Double every second digit from right to left. If doubling of a digit
results in a
two-digit number, add up the two digits to get a single-digit number (like for
12:1+2, 18=1+8).
Step 3. Add all digits in the odd places from right to left in the card number.
6 + 6 + 0 + 8 + 0 + 7 + 8 + 3 = 38
Step 5. If the result from Step 4 is divisible by 10, the card number is valid;
otherwise, it is invalid.
Examples :
Input : 379354508162306
Output : 379354508162306 is Valid
Input : 4388576018402626
Output : 4388576018402626 is invalid
return sum;
}