Majd Rezik
Majd Rezik

Reputation: 99

Is there any alternative explanations why 'Luhn algorithm' is good?

Good Evening guys, I built a simple Java program that validates credit card numbers using Luhn's algorithm / (mod 10). I found a lot of explanations for why it is right to use this formula but still did not understand it fully. Can anyone explain to me why it is a good formula to use for such validation?

Upvotes: 1

Views: 688

Answers (1)

libik
libik

Reputation: 23049

It is just because all the companies agreed to follow this formula and they do not allow any credit card/bank account to exist if it does not follow the Luhn format.

Reason for that is to limit chance of human error.

If you make single typo, it will not pass Luhn alghoritm. Why single typo? Because it is mod 10, if you do typo to one number the difference is from 1 to 9 so the mod 10 covers it.

If you do typo to two numbers and you are unlucky (only 10% of combinations is valid, so there is 10% chance) you can send money to wrong account anyway.

Upvotes: 2

Related Questions