The Luhn formula is used to check if a number is a valid credit card number and in some other scenarios where you need to check a number fast and without accessing a database.
We can summarize the formula as follow:
- We want to check the number `4539 3195 0343 6467`
- We take every second digit starting by the right
- We multiply those digits by 2
- If the result is more than 9 we subtract 9 from it
- We sum all the digits
- If sum is evenly divisible by 10 then this number is valid