Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def checksum(isbn13)
- mod = isbn13.to_s.split(//).collect.with_index{|y,i| i.odd? ? y.to_i * 3 : y.to_i}.inject(:+) % 10
- mod == 0 ? 0 : 10 - mod
- end
- puts checksum(978014300723)
- puts checksum("71")
Add Comment
Please, Sign In to add comment