I have a requirement to generate a unique 8 digit number with one check digit using Luhn algorithm in Java. The number should be unique every time we call the function.
Asked
Active
Viewed 314 times
0
-
The question which you are pointing is to validate the number, but my requirement is to generate the 8 digit number using Luhn algorithm. – user1166528 Jul 13 '16 at 02:30
-
There was a link to https://commons.apache.org/proper/commons-validator/apidocs/org/apache/commons/validator/routines/checkdigit/ModulusCheckDigit.html] – Scary Wombat Jul 13 '16 at 02:36
-
The link is not working... – user1166528 Jul 13 '16 at 06:02
-
Sorry, looks like I appended a `]` on the end my mistake – Scary Wombat Jul 13 '16 at 06:03
-
@user1166528: you only need to generate a unique 7 digit number, then use Luhn algorithm to create the 8th check digit – Hoàng Long Jul 13 '16 at 06:52
-
The Luhn algorithm in gosu is available as github gist here https://gist.github.com/l-ray/a6ecbf2f3b496634ee83 – L-Ray Dec 25 '16 at 20:44