Create a gist now

Instantly share code, notes, and snippets.

Recursion1
list = [1, 2, 3, 4, 5, 6]
def sum(nums)
if nums.size == 0
0
else
n = nums.shift
n + sum(nums)
end
end
puts sum(list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment