Try arithmetic... Without knowing which check digit algorithm you are using, I would not be able to comment. I would normally look at your code and run through the working and non-working values to see what was wrong --- pretty much what you would be doing. I would also check that the results I am TOLD I should get are in fact themselves correct!
But in general, you first have to understand the algorithm. Use paper and pen to run though the steps you would take to get a right answer every time.
Then take your successful method and design the code. You may need a few tweaks, but it should work.
This was first published in September 2004