If python 2 is not working, please use python3.
Program Algorithm
The used algorithm is Luhn algorithm.
This algorithm works by:
-
For each number, from right to left
- First, third, fifth, and on (Odd Columns) multiply by 1
- Second, fourth, fifth, and on(Even Column) multiply by 2
- If, after multiplication, the number is bigger than 9, e.g., 9*2 is 18, make 1 + 8 = 9.
-
Add all digit sum and check by mod 10 using this formula:
- 10 – (sum mod 10), if = 0 then pass else it’s not valid.