Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nusiloot/db54c326f3fe5da31ad434c762621c8f to your computer and use it in GitHub Desktop.
Save nusiloot/db54c326f3fe5da31ad434c762621c8f to your computer and use it in GitHub Desktop.
Netherlands IBAN account number checksum validator
# Netherlands account number algorithm uses this factor table:
# digit | factor
# 1st | 10
# 2nd | 9
# ...
# 10th | 1
#
# After multiplying digits according to the table, sum of these results must be divisible with 11
def validate(acc):
f = 10
total = 0
for a in acc:
total += int(a) * f
f -= 1
return total % 11 == 0
validate("1834239443") # True
validate("1234567890") # False
# Use schwifty module for IBAN validation, however,
# it does not support Netherlands account number validation,
# so validate it seperately with this function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment