simple-exercises/ruby-exercises/easy-7.rb
# Define a method that returns the sum of all the non-negative integers up to and including its argument.
# sum_to(3) => 6
Define a method that returns the sum of all the non-negative integers up to and including its argument.
Define a method that returns the sum of all the non - negative integers up to and including its argument .
def sum_to(int)
  if int <= 0
    return 0
  end
  sum = 0
  (1..int).each do |i|
    sum += i
  end
  sum
end
def sum_to ( int ) if int <= 0 return 0 end sum = 0 ( 1 .. int ) . each do | i | sum += i end sum end
Define a method that returns the sum of all the non-negative integers up to and including its argument.
Define a method that returns the sum of all the non - negative integers up to and including its argument .
int
<not_specific>