in reply to Re^7: Faster Luhn Check Digit Calculation?
in thread Faster Luhn Check Digit Calculation?
Update:Ignore this! It doesn't stand up to syphilis's scrutiny. (It only works for the OPs limited test range by luck!)
Looks fat to me ( just kidding :)
If its skinny you want, try this for (its lack of) size :)
Correct results and 35% faster to boot:
int lookup[] = { 8, 6, 4, 2, 0, 7, 5, 3, 1, 9, 7, 5, 3, 1, 9, 6, 4, 2, + 0 }; int c_fluhn( int n ) { return lookup[ n % 20 ]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: Faster Luhn Check Digit Calculation?
by kschwab (Vicar) on Dec 02, 2018 at 21:55 UTC | |
by BrowserUk (Patriarch) on Dec 02, 2018 at 22:51 UTC | |
by kschwab (Vicar) on Dec 02, 2018 at 23:02 UTC | |
by LanX (Saint) on Dec 02, 2018 at 22:35 UTC | |
by kschwab (Vicar) on Dec 02, 2018 at 22:51 UTC | |
by LanX (Saint) on Dec 03, 2018 at 00:22 UTC | |
by kschwab (Vicar) on Dec 03, 2018 at 01:11 UTC | |
|