Skip to content

Instantly share code, notes, and snippets.

@Epigene
Created March 3, 2015 14:41
Show Gist options
  • Save Epigene/f326c9a3582c031b6dee to your computer and use it in GitHub Desktop.
Save Epigene/f326c9a3582c031b6dee to your computer and use it in GitHub Desktop.
Simple ruby script that sums integers
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