Solution 1: Sum of Integers
Given an array of integers, an integer representing the sum of all numbers in the array. If the array is empty, return 0.
def get_sum(array)
sum = 0
for num in array
sum = sum + num
end
sum
end
Given an array of integers, an integer representing the sum of all numbers in the array. If the array is empty, return 0.
def get_sum(array)
sum = 0
for num in array
sum = sum + num
end
sum
end