luhn_java icon indicating copy to clipboard operation
luhn_java copied to clipboard

Luhn.validate(String) method is incorrect

Open adil-hussain-84 opened this issue 7 years ago • 1 comments

Unless I'm totally missing something in my understanding of the Luhn algorithm I believe your Luhn.validate(String) method is incorrect and misleading for anyone who stumbles across this Git repo from the Luhn algorithm Wiki page.

The Luhn algorithm does not state that the check sum digit must be zero. The Luhn algorithm states that the sum of all the "sum digits" (including the check sum digit) modulo 10 should be 0.

Please fix or remove the link to this repo from the Wiki page. If you add some tests to your code you'll see what I mean. Thanks.

adil-hussain-84 avatar Dec 20 '17 11:12 adil-hussain-84

I also think it looks wrong - seems to have been broken by this commit: https://github.com/nishan/luhn_java/commit/32e724db3131f40671a651569b7a276caa099ecb#diff-f3c575fe7798240d1c8930e125ab53ec

That commit probably fixed one scenario but broke validate().

oskarb avatar Mar 19 '18 23:03 oskarb