Jun's Blog

Output, activities, memo and etc.

Card number checksum

I am reading the book Understanding the Digital World - Brian Kernighan - Japanese translation edition. It's a book to learn computer science as a liberal arts. And I see a checksum algorithm of card number invented in 1954 is interesting. And here it is. The checksum value by the valid card number (16 digits) should be divided by 10.

gist.github.com

$ ruby card.rb
total: NN # Masked
Valid card no.