Created
November 7, 2014 01:34
-
-
Save angelsystem/53aec5f3715f5bffb142 to your computer and use it in GitHub Desktop.
demo suma
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
class SumarDigitos | |
def sumar_numbers(number) | |
sum = 0 | |
number.to_s.each_char do |n| | |
sum = sum + (n.to_i) | |
end | |
sum | |
end | |
end | |
sumar = SumarDigitos.new | |
puts sumar.sumar_numbers(98) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment