Created
March 3, 2015 14:41
-
-
Save Epigene/f326c9a3582c031b6dee to your computer and use it in GitHub Desktop.
Simple ruby script that sums integers
This file contains hidden or 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
s = "" | |
until s == "q" do | |
puts "Enter integers" | |
s = gets.chomp | |
r = s.split("").inject(0){|c,x| c + x.to_i } | |
puts "The sum is #{r}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment