Skip to content

Instantly share code, notes, and snippets.

@mhfs
Created January 29, 2010 17:36
Show Gist options
  • Save mhfs/289927 to your computer and use it in GitHub Desktop.
Save mhfs/289927 to your computer and use it in GitHub Desktop.
def mod10_febraban(value)
result_string = ""
factor = 2
total = 0
value.each_char do |c|
result_string << (c.to_i * factor).to_s
factor = (factor == 2 ? 1 : 2)
end
result_string.each_char { |c| total += c.to_i }
result = 10 - total % 10
result == 10 ? 0 : result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment