Created
April 22, 2015 01:47
-
-
Save squiter/cf4e474b8b51251c5085 to your computer and use it in GitHub Desktop.
Mod 11 - Módulo 11
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
def mod11(number, total) | |
as_string = number.to_s | |
sub = as_string.length | |
value = 0 | |
max = total | |
sub.times do |t| | |
value += as_string[t].to_i * max | |
max = max - 1 | |
end | |
mod = (value % 11) | |
mod = 0 if mod == 0 || mod == 1 | |
digito = total - mod | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment