Last active
December 17, 2015 12:29
-
-
Save sowawa/5610150 to your computer and use it in GitHub Desktop.
luhn check sum(ISO 7812)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"4242424242424242".reverse.chars.each_with_index.map{|ch, index| index.even? ? ch.to_i : (ch.to_i * 2) % 10 + (ch.to_i * 2) / 10 }.inject(:+) % 10 == 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
luhn check
usage