How to validate a Credit Card Number?Most credit card number can be validated using the Luhn algorithm, which is more or a less a glorified Modulo 10 formula!
The Luhn Formula:- Drop the last digit from the number. The last digit is what we want to check against
- Reverse the numbers
- Multiply the digits in odd positions (1, 3, 5, etc.) by 2 and subtract 9 to all any result higher than 9
- Add all the numbers together
- The check digit (the last number of the card) is the amount that you would need to add to get a multiple of 10 (Modulo 10)
For more information about cards, seeCredit Cards Validates:
Visa, MasterCard, Elo, American Express, Discover Network, Hipercard, Diners Club, Aura, Maestro, Good Card, JCB, Sorocred