Our new business venture is getting ready to launch and we need a way to take credit cards. Before sending the customers credit card number off to the payment processor we want to make sure the card number is valid. Today's objective is to create a program to check if a credit card number is valid. Feel free to use an int array if needed.
*Credit cards are validated using the Luhn Algorithm with an expected check digit of modulo 10.
Comments:
Anonymous - 10 years, 5 months ago
Late and not optimal but still haskell :D
i split the input into 4 numbers (a wrapper is pretty simple so i left it out here)
reply permalink
Anonymous - 10 years, 5 months ago
reply permalink
bumbleguppy - 10 years, 5 months ago
The wiki page links to a much better javascript solution, but this was good exercise for me anyway.
reply permalink
David - 10 years, 5 months ago
Have some C. It's good for you. ''' #include <stdio.h> #include <math.h>
I also decided to break up the number into 4 parts, since the number on the card if often separated that way.
reply permalink