-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathluhn.format.txt
20 lines (16 loc) · 1.11 KB
/
luhn.format.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
┏━━━━━━━━━━┓
┃ LUHN ┃
┗━━━━━━━━━━┛
GOAL ==> #Checksum of a number (ISO/IEC 7812-1)
#Used for credit card numbers and some national identifiers
CALCULATION ==> #Creating:
# - for every second digit, starting from right: NUM *= 2; if (NUM > 9) NUM -= 9
# - appended as last digit: 10 - (SUM(all digits) % 10)
#Verifying:
# - same step 1
# - SUM(all digits) % 10 === 0
#Can also use a different radix than 10 ("Luhn mod N algo")
PROPERTIES ==> # - simple
# - catches one digit errors
# - but not more complex errors
# - can padd 0 to left without changing checksum